diff --git a/service/raft/raft_group_registry.cc b/service/raft/raft_group_registry.cc index ca8a00796f..683a9b681d 100644 --- a/service/raft/raft_group_registry.cc +++ b/service/raft/raft_group_registry.cc @@ -189,7 +189,7 @@ raft_group_registry::server_for_group raft_group_registry::create_server_for_gro auto rpc = std::make_unique(_ms, *this, gid, my_id); // Keep a reference to a specific RPC class. auto& rpc_ref = *rpc; - auto storage = std::make_unique(_qp.local(), gid); + auto storage = std::make_unique(_qp.local(), gid, my_id); auto state_machine = std::make_unique(); auto server = raft::create_server(my_id, std::move(rpc), std::move(state_machine), std::move(storage), _fd, raft::server::configuration()); diff --git a/service/raft/raft_sys_table_storage.cc b/service/raft/raft_sys_table_storage.cc index d5bfb398f7..1124ee6262 100644 --- a/service/raft/raft_sys_table_storage.cc +++ b/service/raft/raft_sys_table_storage.cc @@ -38,8 +38,9 @@ namespace service { -raft_sys_table_storage::raft_sys_table_storage(cql3::query_processor& qp, raft::group_id gid) +raft_sys_table_storage::raft_sys_table_storage(cql3::query_processor& qp, raft::group_id gid, raft::server_id server_id) : _group_id(std::move(gid)) + , _server_id(std::move(server_id)) , _qp(qp) , _dummy_query_state(service::client_state::for_internal_calls(), empty_service_permit()) , _pending_op_fut(make_ready_future<>()) diff --git a/service/raft/raft_sys_table_storage.hh b/service/raft/raft_sys_table_storage.hh index 6477d86c61..4a58cc91ab 100644 --- a/service/raft/raft_sys_table_storage.hh +++ b/service/raft/raft_sys_table_storage.hh @@ -50,6 +50,7 @@ namespace service { // Uses "raft" system table as a backend storage to persist raft state. class raft_sys_table_storage : public raft::persistence { raft::group_id _group_id; + raft::server_id _server_id; // Prepared statement instance used for construction of batch statements on // `store_log_entries` calls. shared_ptr _store_entry_stmt; @@ -64,7 +65,7 @@ class raft_sys_table_storage : public raft::persistence { future<> _pending_op_fut; public: - explicit raft_sys_table_storage(cql3::query_processor& qp, raft::group_id gid); + explicit raft_sys_table_storage(cql3::query_processor& qp, raft::group_id gid, raft::server_id server_id); future<> store_term_and_vote(raft::term_t term, raft::server_id vote) override; future> load_term_and_vote() override; diff --git a/test/raft/raft_sys_table_storage_test.cc b/test/raft/raft_sys_table_storage_test.cc index 7fdda5cd7a..2586e78a78 100644 --- a/test/raft/raft_sys_table_storage_test.cc +++ b/test/raft/raft_sys_table_storage_test.cc @@ -88,7 +88,7 @@ static std::vector create_test_log() { SEASTAR_TEST_CASE(test_store_load_term_and_vote) { return do_with_cql_env([] (cql_test_env& env) -> future<> { cql3::query_processor& qp = env.local_qp(); - raft_sys_table_storage storage(qp, gid); + raft_sys_table_storage storage(qp, gid, raft::server_id::create_random_id()); raft::term_t vote_term(1); auto vote_id = raft::server_id::create_random_id(); @@ -104,7 +104,7 @@ SEASTAR_TEST_CASE(test_store_load_term_and_vote) { SEASTAR_TEST_CASE(test_store_load_snapshot) { return do_with_cql_env([] (cql_test_env& env) -> future<> { cql3::query_processor& qp = env.local_qp(); - raft_sys_table_storage storage(qp, gid); + raft_sys_table_storage storage(qp, gid, raft::server_id::create_random_id()); raft::term_t snp_term(1); raft::index_t snp_idx(1); @@ -130,7 +130,7 @@ SEASTAR_TEST_CASE(test_store_load_snapshot) { SEASTAR_TEST_CASE(test_store_load_log_entries) { return do_with_cql_env([] (cql_test_env& env) -> future<> { cql3::query_processor& qp = env.local_qp(); - raft_sys_table_storage storage(qp, gid); + raft_sys_table_storage storage(qp, gid, raft::server_id::create_random_id()); std::vector entries = create_test_log(); co_await storage.store_log_entries(entries); @@ -146,7 +146,7 @@ SEASTAR_TEST_CASE(test_store_load_log_entries) { SEASTAR_TEST_CASE(test_truncate_log) { return do_with_cql_env([] (cql_test_env& env) -> future<> { cql3::query_processor& qp = env.local_qp(); - raft_sys_table_storage storage(qp, gid); + raft_sys_table_storage storage(qp, gid, raft::server_id::create_random_id()); std::vector entries = create_test_log(); co_await storage.store_log_entries(entries); @@ -164,7 +164,7 @@ SEASTAR_TEST_CASE(test_truncate_log) { SEASTAR_TEST_CASE(test_store_snapshot_truncate_log_tail) { return do_with_cql_env([] (cql_test_env& env) -> future<> { cql3::query_processor& qp = env.local_qp(); - raft_sys_table_storage storage(qp, gid); + raft_sys_table_storage storage(qp, gid, raft::server_id::create_random_id()); std::vector entries = create_test_log(); co_await storage.store_log_entries(entries);