From 26dd7985a83b54abaa4d40a2245944e660ebbbf0 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Fri, 28 Jul 2023 12:28:29 +0300 Subject: [PATCH] system_keyspace: De-static get_last_group0_state_id() The caller is raft_group0_client with sys.ks. dependency reference and group0_state_machine with raft_group0_client exporing its sys.ks. This makes it possible to instantly drop one more qctx reference Signed-off-by: Pavel Emelyanov --- db/system_keyspace.cc | 2 +- db/system_keyspace.hh | 2 +- service/raft/group0_state_machine.cc | 2 +- service/raft/raft_group0_client.cc | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/db/system_keyspace.cc b/db/system_keyspace.cc index 950aa8a8ea..76da0e628c 100644 --- a/db/system_keyspace.cc +++ b/db/system_keyspace.cc @@ -2384,7 +2384,7 @@ future<> system_keyspace::set_raft_group0_id(utils::UUID uuid) { static constexpr auto GROUP0_HISTORY_KEY = "history"; future system_keyspace::get_last_group0_state_id() { - auto rs = co_await qctx->execute_cql( + auto rs = co_await execute_cql( format( "SELECT state_id FROM system.{} WHERE key = '{}' LIMIT 1", GROUP0_HISTORY, GROUP0_HISTORY_KEY)); diff --git a/db/system_keyspace.hh b/db/system_keyspace.hh index 683b7c634d..69c22bbd4c 100644 --- a/db/system_keyspace.hh +++ b/db/system_keyspace.hh @@ -454,7 +454,7 @@ public: // Get the last (the greatest in timeuuid order) state ID in the group 0 history table. // Assumes that the history table exists, i.e. Raft experimental feature is enabled. - static future get_last_group0_state_id(); + future get_last_group0_state_id(); // Checks whether the group 0 history table contains the given state ID. // Assumes that the history table exists, i.e. Raft experimental feature is enabled. diff --git a/service/raft/group0_state_machine.cc b/service/raft/group0_state_machine.cc index fd562789a9..92d9071060 100644 --- a/service/raft/group0_state_machine.cc +++ b/service/raft/group0_state_machine.cc @@ -117,7 +117,7 @@ future<> group0_state_machine::apply(std::vector command) { // max_mutation_size = 1/2 of commitlog segment size, thus max_command_size is set 1/3 of commitlog segment size to leave space for metadata. size_t max_command_size = _sp.data_dictionary().get_config().commitlog_segment_size_in_mb() * 1024 * 1024 / 3; - group0_state_machine_merger m(co_await db::system_keyspace::get_last_group0_state_id(), std::move(read_apply_mutex_holder), + group0_state_machine_merger m(co_await _client.sys_ks().get_last_group0_state_id(), std::move(read_apply_mutex_holder), max_command_size, _sp.data_dictionary()); for (auto&& c : command) { diff --git a/service/raft/raft_group0_client.cc b/service/raft/raft_group0_client.cc index a0f867a918..77393fdeda 100644 --- a/service/raft/raft_group0_client.cc +++ b/service/raft/raft_group0_client.cc @@ -249,7 +249,7 @@ future raft_group0_client::start_operation(seastar::abort_source* // Read barrier may wait for `group0_state_machine::apply` which also takes this mutex. auto read_apply_holder = co_await hold_read_apply_mutex(); - auto observed_group0_state_id = co_await db::system_keyspace::get_last_group0_state_id(); + auto observed_group0_state_id = co_await _sys_ks.get_last_group0_state_id(); auto new_group0_state_id = generate_group0_state_id(observed_group0_state_id); co_return group0_guard {