raft: create system tables only when raft experimental feature is set
Also introduce a tiny function to return raft-enabled db config for cql testing. Tests: unit(dev) Signed-off-by: Pavel Solodovnikov <pa.solodovnikov@scylladb.com> Message-Id: <20210826091432.279532-1-pa.solodovnikov@scylladb.com>
This commit is contained in:
committed by
Avi Kivity
parent
bd8fa47d84
commit
c0854a0f62
@@ -1947,7 +1947,7 @@ void register_virtual_tables(service::storage_service& ss) {
|
||||
add_table(std::make_unique<describe_ring_table>(ss));
|
||||
}
|
||||
|
||||
std::vector<schema_ptr> all_tables() {
|
||||
std::vector<schema_ptr> all_tables(const db::config& cfg) {
|
||||
std::vector<schema_ptr> r;
|
||||
auto schema_tables = db::schema_tables::all_tables(schema_features::full());
|
||||
std::copy(schema_tables.begin(), schema_tables.end(), std::back_inserter(r));
|
||||
@@ -1956,12 +1956,14 @@ std::vector<schema_ptr> all_tables() {
|
||||
compactions_in_progress(), compaction_history(),
|
||||
sstable_activity(), clients(), size_estimates(), large_partitions(), large_rows(), large_cells(),
|
||||
scylla_local(), db::schema_tables::scylla_table_schema_history(),
|
||||
raft(), raft_snapshots(),
|
||||
v3::views_builds_in_progress(), v3::built_views(),
|
||||
v3::scylla_views_builds_in_progress(),
|
||||
v3::truncated(),
|
||||
v3::cdc_local(),
|
||||
});
|
||||
if (cfg.check_experimental(db::experimental_features_t::RAFT)) {
|
||||
r.insert(r.end(), {raft(), raft_snapshots()});
|
||||
}
|
||||
// legacy schema
|
||||
r.insert(r.end(), {
|
||||
// TODO: once we migrate hints/batchlog and add convertor
|
||||
@@ -1997,9 +1999,10 @@ static bool maybe_write_in_user_memory(schema_ptr s, database& db) {
|
||||
future<> make(database& db, service::storage_service& ss) {
|
||||
register_virtual_tables(ss);
|
||||
|
||||
auto enable_cache = db.get_config().enable_cache();
|
||||
bool durable = db.get_config().data_file_directories().size() > 0;
|
||||
for (auto&& table : all_tables()) {
|
||||
auto& db_config = db.get_config();
|
||||
auto enable_cache = db_config.enable_cache();
|
||||
bool durable = db_config.data_file_directories().size() > 0;
|
||||
for (auto&& table : all_tables(db_config)) {
|
||||
auto ks_name = table->ks_name();
|
||||
if (!db.has_keyspace(ks_name)) {
|
||||
auto ksm = make_lw_shared<keyspace_metadata>(ks_name,
|
||||
|
||||
@@ -90,6 +90,8 @@ namespace db {
|
||||
|
||||
sstring system_keyspace_name();
|
||||
|
||||
class config;
|
||||
|
||||
namespace system_keyspace {
|
||||
|
||||
static constexpr auto NAME = "system";
|
||||
@@ -213,7 +215,7 @@ future<> remove_endpoint(gms::inet_address ep);
|
||||
future<> set_scylla_local_param(const sstring& key, const sstring& value);
|
||||
future<std::optional<sstring>> get_scylla_local_param(const sstring& key);
|
||||
|
||||
std::vector<schema_ptr> all_tables();
|
||||
std::vector<schema_ptr> all_tables(const db::config& cfg);
|
||||
future<> make(database& db, service::storage_service& ss);
|
||||
|
||||
/// overloads
|
||||
|
||||
@@ -805,5 +805,5 @@ SEASTAR_TEST_CASE(test_schema_tables_use_null_sharder) {
|
||||
BOOST_REQUIRE_EQUAL(s->get_sharder().shard_count(), 1);
|
||||
}
|
||||
}).get();
|
||||
});
|
||||
}, raft_cql_test_config());
|
||||
}
|
||||
|
||||
@@ -685,12 +685,18 @@ public:
|
||||
|
||||
sys_dist_ks.start(std::ref(qp), std::ref(mm), std::ref(proxy)).get();
|
||||
|
||||
// We need to have a system keyspace started and
|
||||
// initialized to initialize Raft service.
|
||||
raft_gr.invoke_on_all(&service::raft_group_registry::init).get();
|
||||
const bool raft_enabled = cfg->check_experimental(db::experimental_features_t::RAFT);
|
||||
if (raft_enabled) {
|
||||
// We need to have a system keyspace started and
|
||||
// initialized to initialize Raft service.
|
||||
raft_gr.invoke_on_all(&service::raft_group_registry::init).get();
|
||||
}
|
||||
auto stop_raft_rpc = defer([&raft_gr] {
|
||||
raft_gr.invoke_on_all(&service::raft_group_registry::uninit).get();
|
||||
});
|
||||
if (!raft_enabled) {
|
||||
stop_raft_rpc.cancel();
|
||||
}
|
||||
|
||||
cdc_generation_service.start(std::ref(*cfg), std::ref(gms::get_gossiper()), std::ref(sys_dist_ks), std::ref(abort_sources), std::ref(token_metadata), std::ref(feature_service)).get();
|
||||
auto stop_cdc_generation_service = defer([&cdc_generation_service] {
|
||||
@@ -811,6 +817,12 @@ reader_permit make_reader_permit(cql_test_env& env) {
|
||||
return env.local_db().get_reader_concurrency_semaphore().make_tracking_only_permit(nullptr, "test", db::no_timeout);
|
||||
}
|
||||
|
||||
cql_test_config raft_cql_test_config() {
|
||||
cql_test_config c;
|
||||
c.db_config->experimental_features({db::experimental_features_t::RAFT});
|
||||
return c;
|
||||
}
|
||||
|
||||
namespace debug {
|
||||
|
||||
seastar::sharded<database>* db;
|
||||
|
||||
@@ -168,3 +168,6 @@ future<> do_with_cql_env(std::function<future<>(cql_test_env&)> func, cql_test_c
|
||||
future<> do_with_cql_env_thread(std::function<void(cql_test_env&)> func, cql_test_config = {}, thread_attributes thread_attr = {});
|
||||
|
||||
reader_permit make_reader_permit(cql_test_env&);
|
||||
|
||||
// CQL test config with raft experimental feature enabled
|
||||
cql_test_config raft_cql_test_config();
|
||||
|
||||
@@ -98,7 +98,7 @@ SEASTAR_TEST_CASE(test_store_load_term_and_vote) {
|
||||
|
||||
BOOST_CHECK_EQUAL(vote_term, persisted.first);
|
||||
BOOST_CHECK_EQUAL(vote_id, persisted.second);
|
||||
});
|
||||
}, raft_cql_test_config());
|
||||
}
|
||||
|
||||
SEASTAR_TEST_CASE(test_store_load_snapshot) {
|
||||
@@ -124,7 +124,7 @@ SEASTAR_TEST_CASE(test_store_load_snapshot) {
|
||||
raft::snapshot loaded_snp = co_await storage.load_snapshot();
|
||||
|
||||
BOOST_CHECK(snp == loaded_snp);
|
||||
});
|
||||
}, raft_cql_test_config());
|
||||
}
|
||||
|
||||
SEASTAR_TEST_CASE(test_store_load_log_entries) {
|
||||
@@ -140,7 +140,7 @@ SEASTAR_TEST_CASE(test_store_load_log_entries) {
|
||||
for (size_t i = 0, end = entries.size(); i != end; ++i) {
|
||||
BOOST_CHECK(*entries[i] == *loaded_entries[i]);
|
||||
}
|
||||
});
|
||||
}, raft_cql_test_config());
|
||||
}
|
||||
|
||||
SEASTAR_TEST_CASE(test_truncate_log) {
|
||||
@@ -158,7 +158,7 @@ SEASTAR_TEST_CASE(test_truncate_log) {
|
||||
for (size_t i = 0, end = loaded_entries.size(); i != end; ++i) {
|
||||
BOOST_CHECK(*entries[i] == *loaded_entries[i]);
|
||||
}
|
||||
});
|
||||
}, raft_cql_test_config());
|
||||
}
|
||||
|
||||
SEASTAR_TEST_CASE(test_store_snapshot_truncate_log_tail) {
|
||||
@@ -189,5 +189,5 @@ SEASTAR_TEST_CASE(test_store_snapshot_truncate_log_tail) {
|
||||
for (size_t i = 0, end = loaded_entries.size(); i != end; ++i) {
|
||||
BOOST_CHECK(*entries[i + 1] == *loaded_entries[i]);
|
||||
}
|
||||
});
|
||||
}, raft_cql_test_config());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user