table: snapshot: add skip_flush option

skip_flush is false by default.

Also, log a debug message when starting the snapshot.

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
This commit is contained in:
Benny Halevy
2021-06-02 16:08:42 +03:00
parent 4169f56407
commit 52fd2b71b7
2 changed files with 7 additions and 5 deletions

View File

@@ -804,7 +804,7 @@ public:
db::replay_position set_low_replay_position_mark();
future<> snapshot(database& db, sstring name);
future<> snapshot(database& db, sstring name, bool skip_flush = false);
future<std::unordered_map<sstring, snapshot_details>> get_snapshot_details();
/*!

View File

@@ -1363,11 +1363,13 @@ future<> table::write_schema_as_cql(database& db, sstring dir) const {
}
future<> table::snapshot(database& db, sstring name) {
return flush().then([this, &db, name = std::move(name)]() {
return with_semaphore(_sstable_deletion_sem, 1, [this, &db, name = std::move(name)]() {
future<> table::snapshot(database& db, sstring name, bool skip_flush) {
auto jsondir = _config.datadir + "/snapshots/" + name;
tlogger.debug("snapshot {}: skip_flush={}", jsondir, skip_flush);
auto f = skip_flush ? make_ready_future<>() : flush();
return f.then([this, &db, jsondir = std::move(jsondir)]() {
return with_semaphore(_sstable_deletion_sem, 1, [this, &db, jsondir = std::move(jsondir)]() {
auto tables = boost::copy_range<std::vector<sstables::shared_sstable>>(*_sstables->all());
auto jsondir = _config.datadir + "/snapshots/" + name;
return do_with(std::move(tables), std::move(jsondir), [this, &db] (std::vector<sstables::shared_sstable>& tables, const sstring& jsondir) {
return io_check([&jsondir] { return recursive_touch_directory(jsondir); }).then([this, &db, &jsondir, &tables] {
return max_concurrent_for_each(tables, db.get_config().initial_sstable_loading_concurrency(), [&db, &jsondir] (sstables::shared_sstable sstable) {