table: snapshot_on_all_shards: Get directory from storage options
There are several things that are changed here - The target directory for snapshot is evaluated using table directory taken from its storage options, not from config - If the storage options are not "local", the snapshot_on_all_shards is failed early, it's impossible to snapshot sstables anyway - If the storage is not configured for the obtained local options, snapshotting is skilled, because it's a virtual table that's probably not supposed to have snapshots - The late failure to snapshot non-local sstables is converted into internal error, as this functionality cannot be executed as per previous change - The target path is created using fs::path operator/ overload, not by concatenating strings (it's minor change) Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
@@ -2595,7 +2595,15 @@ future<> table::write_schema_as_cql(database& db, sstring dir) const {
|
||||
|
||||
// Runs the orchestration code on an arbitrary shard to balance the load.
|
||||
future<> table::snapshot_on_all_shards(sharded<database>& sharded_db, const global_table_ptr& table_shards, sstring name) {
|
||||
auto jsondir = table_shards->_config.datadir + "/snapshots/" + name;
|
||||
auto* so = std::get_if<storage_options::local>(&table_shards->get_storage_options().value);
|
||||
if (so == nullptr) {
|
||||
throw std::runtime_error("Snapshotting non-local tables is not implemented");
|
||||
}
|
||||
if (so->dir.empty()) { // virtual tables don't have initialized local storage
|
||||
co_return;
|
||||
}
|
||||
|
||||
auto jsondir = (so->dir / sstables::snapshots_dir / name).native();
|
||||
auto orchestrator = std::hash<sstring>()(jsondir) % smp::count;
|
||||
|
||||
co_await smp::submit_to(orchestrator, [&] () -> future<> {
|
||||
|
||||
@@ -643,7 +643,8 @@ future<> s3_storage::remove_by_registry_entry(entry_descriptor desc) {
|
||||
}
|
||||
|
||||
future<> s3_storage::snapshot(const sstable& sst, sstring dir, absolute_path abs, std::optional<generation_type> gen) const {
|
||||
co_await coroutine::return_exception(std::runtime_error("Snapshotting S3 objects not implemented"));
|
||||
on_internal_error(sstlog, "Snapshotting S3 objects not implemented");
|
||||
co_return;
|
||||
}
|
||||
|
||||
std::unique_ptr<sstables::storage> make_storage(sstables_manager& manager, const data_dictionary::storage_options& s_opts, sstable_state state) {
|
||||
|
||||
Reference in New Issue
Block a user