mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-02 13:06:57 +00:00
table: Use directory_semaphore for rate-limited snapshot taking
The table::take_snapshot() limits its parallelizm with the help of direcoty semaphore already, but implements it "by hand". There's already parallel_for_each() method on the dir.sem. class that does exactly that. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
@@ -2305,13 +2305,11 @@ future<table::snapshot_file_set> table::take_snapshot(database& db, sstring json
|
||||
auto table_names = std::make_unique<std::unordered_set<sstring>>();
|
||||
|
||||
co_await io_check([&jsondir] { return recursive_touch_directory(jsondir); });
|
||||
co_await max_concurrent_for_each(tables, db.get_sharded_sst_dir_semaphore().local()._concurrency, [&db, &jsondir, &table_names] (sstables::shared_sstable sstable) {
|
||||
co_await db.get_sharded_sst_dir_semaphore().local().parallel_for_each(tables, [&jsondir, &table_names] (sstables::shared_sstable sstable) {
|
||||
table_names->insert(sstable->component_basename(sstables::component_type::Data));
|
||||
return with_semaphore(db.get_sharded_sst_dir_semaphore().local()._sem, 1, [&jsondir, sstable] {
|
||||
return io_check([sstable, &dir = jsondir] {
|
||||
return sstable->snapshot(dir);
|
||||
});
|
||||
});
|
||||
});
|
||||
co_await io_check(sync_directory, jsondir);
|
||||
co_return make_foreign(std::move(table_names));
|
||||
|
||||
@@ -45,8 +45,6 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
friend class ::replica::table; // FIXME table snapshots should switch to sstable_directory
|
||||
|
||||
template <std::ranges::range Container, typename Func>
|
||||
requires std::is_invocable_r_v<future<>, Func, typename std::ranges::range_value_t<Container>&>
|
||||
future<> parallel_for_each(Container& c, Func func) {
|
||||
|
||||
Reference in New Issue
Block a user