Skip to content

Commit

Permalink
system_keyspace: De-static system_keyspace::increment_and_get_generation
Browse files Browse the repository at this point in the history
It's only called on cluster-join from storage_service which has the
local system_keyspace reference and it's already started by that time.

This allows removing few more occurrences of global qctx.

Signed-off-by: Pavel Emelyanov <[email protected]>
  • Loading branch information
xemul committed Jan 20, 2023
1 parent 4c4f8aa commit be2ad2f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions db/system_keyspace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3022,7 +3022,7 @@ future<> system_keyspace::get_repair_history(::table_id table_id, repair_history

future<int> system_keyspace::increment_and_get_generation() {
auto req = format("SELECT gossip_generation FROM system.{} WHERE key='{}'", LOCAL, LOCAL);
auto rs = co_await qctx->qp().execute_internal(req, cql3::query_processor::cache_internal::yes);
auto rs = co_await _qp.local().execute_internal(req, cql3::query_processor::cache_internal::yes);
int generation;
if (rs->empty() || !rs->one().has("gossip_generation")) {
// seconds-since-epoch isn't a foolproof new generation
Expand All @@ -3042,7 +3042,7 @@ future<int> system_keyspace::increment_and_get_generation() {
}
}
req = format("INSERT INTO system.{} (key, gossip_generation) VALUES ('{}', ?)", LOCAL, LOCAL);
co_await qctx->qp().execute_internal(req, {generation}, cql3::query_processor::cache_internal::yes);
co_await _qp.local().execute_internal(req, {generation}, cql3::query_processor::cache_internal::yes);
co_await force_blocking_flush(LOCAL);
co_return generation;
}
Expand Down
2 changes: 1 addition & 1 deletion db/system_keyspace.hh
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public:

static future<std::unordered_map<gms::inet_address, sstring>> load_peer_features();

static future<int> increment_and_get_generation();
future<int> increment_and_get_generation();
bool bootstrap_needed() const;
bool bootstrap_complete() const;
bool bootstrap_in_progress() const;
Expand Down
2 changes: 1 addition & 1 deletion service/storage_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ future<> storage_service::join_token_ring(cdc::generation_service& cdc_gen_servi

slogger.info("Starting up server gossip");

auto generation_number = co_await db::system_keyspace::increment_and_get_generation();
auto generation_number = co_await _sys_ks.local().increment_and_get_generation();
auto advertise = gms::advertise_myself(!replacing_a_node_with_same_ip);
co_await _gossiper.start_gossiping(generation_number, app_states, advertise);

Expand Down

0 comments on commit be2ad2f

Please sign in to comment.