diff --git a/replica/database.hh b/replica/database.hh index c39a18aa88..9aed29223c 100644 --- a/replica/database.hh +++ b/replica/database.hh @@ -1041,8 +1041,6 @@ private: using snapshot_file_set = foreign_ptr>>; future, sstable_list_permit>> snapshot_sstables(); - // Writes the table schema and the manifest of all files in the snapshot directory. - future<> finalize_snapshot(const global_table_ptr& table_shards, sstring jsondir, std::vector file_sets); static future<> seal_snapshot(sstring jsondir, std::vector file_sets); public: static future<> snapshot_on_all_shards(sharded& sharded_db, const global_table_ptr& table_shards, sstring name); diff --git a/replica/table.cc b/replica/table.cc index 5d0e931570..25e49d708b 100644 --- a/replica/table.cc +++ b/replica/table.cc @@ -3306,7 +3306,22 @@ future<> table::snapshot_on_all_shards(sharded& sharded_db, const glob }); co_await io_check(sync_directory, jsondir); - co_await t.finalize_snapshot(table_shards, std::move(jsondir), std::move(file_sets)); + std::exception_ptr ex; + + tlogger.debug("snapshot {}: writing schema.cql", jsondir); + co_await t.write_schema_as_cql(table_shards, jsondir).handle_exception([&] (std::exception_ptr ptr) { + tlogger.error("Failed writing schema file in snapshot in {} with exception {}", jsondir, ptr); + ex = std::move(ptr); + }); + tlogger.debug("snapshot {}: seal_snapshot", jsondir); + co_await seal_snapshot(jsondir, std::move(file_sets)).handle_exception([&] (std::exception_ptr ptr) { + tlogger.error("Failed to seal snapshot in {}: {}.", jsondir, ptr); + ex = std::move(ptr); + }); + + if (ex) { + co_await coroutine::return_exception_ptr(std::move(ex)); + } }); } @@ -3316,25 +3331,6 @@ future, table::sstable_list_perm co_return std::make_pair(std::move(tables), std::move(permit)); } -future<> table::finalize_snapshot(const global_table_ptr& table_shards, sstring jsondir, std::vector file_sets) { - std::exception_ptr ex; - - tlogger.debug("snapshot {}: writing schema.cql", jsondir); - co_await write_schema_as_cql(table_shards, jsondir).handle_exception([&] (std::exception_ptr ptr) { - tlogger.error("Failed writing schema file in snapshot in {} with exception {}", jsondir, ptr); - ex = std::move(ptr); - }); - tlogger.debug("snapshot {}: seal_snapshot", jsondir); - co_await seal_snapshot(jsondir, std::move(file_sets)).handle_exception([&] (std::exception_ptr ptr) { - tlogger.error("Failed to seal snapshot in {}: {}.", jsondir, ptr); - ex = std::move(ptr); - }); - - if (ex) { - co_await coroutine::return_exception_ptr(std::move(ex)); - } -} - future table::snapshot_exists(sstring tag) { auto* so = std::get_if(&_storage_opts->value); if (so == nullptr || so->dir.empty()) {