"
Making the system-keyspace into a standard sharded instance will
help to fix several dependency knots.
First, the global qctx and local-cache both will be moved onto the
sys-ks, all their users will be patched to depend on system-keyspace.
Now it's not quite so, but we're moving towards this state.
Second, snitch instance now sits in the middle of another dependency
loop. To untie one the preferred ip and dc/rack info should be
moved onto system keyspace altogether (now it's scattered over several
places). The sys-ks thus needs to be a sharded service with some
state.
This set makes system-keyspace sharded instance, equipps it with all
the dependencies it needs and passes it as dependency into storage
service, migration manager and API. This helps eliminating a good
portion of global qctx/cache usage and prepares the ground for snitch
rework.
tests: unit(dev)
v1: unit(debug), dtest.simple_boot_shutdown(dev)
"
* 'br-sharded-system-keyspace-instance-2' of https://github.com/xemul/scylla: (25 commits)
system_keyspace: Make load_host_ids non-static
system_keyspace: Make load_tokens non-static
system_keyspace: Make remove_endpoint and update_tokens non-static
system_keyspace: Coroutinize update_tokens
system_keyspace: Coroutinize remove_endpoint
system_keyspace: Make update_cached_values non-static
system_keyspace: Coroutinuze update_peer_info
system_keyspace: Make update_schema_version non-static
schema_tables: Add sharded<system_keyspace> argument to update_schema_version_and_announce
replica: Push sharded<system_keyspace> down to parse_system_tables
api: Carry sharded<system_keyspace> reference along
storage_service: Keep sharded<system_keyspace> reference
migration_manager: Keep sharded<system_keyspace> reference
system_keyspace: Remove temporary qp variable
system_keyspace: Make get_preferred_ips non-static
system_keyspace: Make cache_truncation_record non-static
system_keyspace: Make check_health non-static
system_keyspace: Make build_bootstrap_info non-static
system_keyspace: Make build_dc_rack_info non-static
system_keyspace: Make setup_version non-static
...
95 lines
3.7 KiB
C++
95 lines
3.7 KiB
C++
/*
|
|
* Copyright (C) 2018-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
#include <seastar/core/future.hh>
|
|
#include <seastar/core/distributed.hh>
|
|
#include <seastar/core/sstring.hh>
|
|
#include <seastar/core/file.hh>
|
|
#include <seastar/util/bool_class.hh>
|
|
#include <vector>
|
|
#include <functional>
|
|
#include <filesystem>
|
|
#include "seastarx.hh"
|
|
#include "compaction/compaction_descriptor.hh"
|
|
|
|
namespace replica {
|
|
class database;
|
|
class table;
|
|
using column_family = table;
|
|
}
|
|
|
|
namespace db {
|
|
class config;
|
|
class system_distributed_keyspace;
|
|
class system_keyspace;
|
|
namespace view {
|
|
class view_update_generator;
|
|
}
|
|
}
|
|
|
|
namespace sstables {
|
|
|
|
class entry_descriptor;
|
|
class foreign_sstable_open_info;
|
|
class sstable_directory;
|
|
|
|
}
|
|
|
|
namespace service {
|
|
|
|
class storage_proxy;
|
|
class storage_service;
|
|
|
|
}
|
|
|
|
namespace gms {
|
|
class gossiper;
|
|
}
|
|
|
|
class distributed_loader_for_tests;
|
|
|
|
namespace replica {
|
|
|
|
class distributed_loader {
|
|
friend class ::distributed_loader_for_tests;
|
|
|
|
static future<> reshape(sharded<sstables::sstable_directory>& dir, sharded<replica::database>& db, sstables::reshape_mode mode,
|
|
sstring ks_name, sstring table_name, sstables::compaction_sstable_creator_fn creator, std::function<bool (const sstables::shared_sstable&)> filter);
|
|
static future<> reshard(sharded<sstables::sstable_directory>& dir, sharded<replica::database>& db, sstring ks_name, sstring table_name, sstables::compaction_sstable_creator_fn creator);
|
|
static future<> process_sstable_dir(sharded<sstables::sstable_directory>& dir, bool sort_sstables_according_to_owner = true);
|
|
static future<> lock_table(sharded<sstables::sstable_directory>& dir, sharded<replica::database>& db, sstring ks_name, sstring cf_name);
|
|
static future<size_t> make_sstables_available(sstables::sstable_directory& dir,
|
|
sharded<replica::database>& db, sharded<db::view::view_update_generator>& view_update_generator,
|
|
std::filesystem::path datadir, sstring ks, sstring cf);
|
|
using allow_offstrategy_compaction = bool_class<struct allow_offstrategy_compaction_tag>;
|
|
using must_exist = bool_class<struct must_exist_tag>;
|
|
static future<> populate_column_family(distributed<replica::database>& db, sstring sstdir, sstring ks, sstring cf, allow_offstrategy_compaction, must_exist = must_exist::yes);
|
|
static future<> populate_keyspace(distributed<replica::database>& db, sstring datadir, sstring ks_name);
|
|
static future<> cleanup_column_family_temp_sst_dirs(sstring sstdir);
|
|
static future<> handle_sstables_pending_delete(sstring pending_deletes_dir);
|
|
|
|
public:
|
|
static future<> init_system_keyspace(distributed<replica::database>& db, distributed<service::storage_service>& ss, sharded<gms::gossiper>& g, db::config& cfg);
|
|
static future<> init_non_system_keyspaces(distributed<replica::database>& db, distributed<service::storage_proxy>& proxy, sharded<db::system_keyspace>& sys_ks);
|
|
static future<> ensure_system_table_directories(distributed<replica::database>& db);
|
|
|
|
// Scan sstables under upload directory. Return a vector with smp::count entries.
|
|
// Each entry with index of idx should be accessed on shard idx only.
|
|
// Each entry contains a vector of sstables for this shard.
|
|
// The table UUID is returned too.
|
|
static future<std::tuple<utils::UUID, std::vector<std::vector<sstables::shared_sstable>>>>
|
|
get_sstables_from_upload_dir(distributed<replica::database>& db, sstring ks, sstring cf);
|
|
static future<> process_upload_dir(distributed<replica::database>& db, distributed<db::system_distributed_keyspace>& sys_dist_ks,
|
|
distributed<db::view::view_update_generator>& view_update_generator, sstring ks_name, sstring cf_name);
|
|
};
|
|
|
|
}
|