topology_state_machine: Introduce lock transition

Will be used in load balancer tests to prevent concurrent topology
operations, in particular background load balancing.

load balancer will be invoked explicitly by the test. Disabling load
balancer in topology is not a solution, because we want the explicit
call to perform the load balancing.
This commit is contained in:
Tomasz Grabiec
2025-02-01 00:04:27 +01:00
parent 3bb19e9ac9
commit 61532eb53b
5 changed files with 11 additions and 0 deletions

View File

@@ -124,6 +124,9 @@ Additionally to specific node states, there entire topology can also be in a tra
it from group 0. We also use this state to rollback a failed bootstrap or decommission.
- `rollback_to_normal` - the decommission or removenode operation failed. Rollback the operation by
moving the node we tried to decommission/remove back to the normal state.
- `lock` - the topology stays in this state until externally changed (to null state), preventing topology
requests from starting. Intended to be used in tests which want to prevent internally-triggered topology
operations during the test.
When a node bootstraps, we create new tokens for it and a new CDC generation
and enter the `commit_cdc_generation` state. Once the generation is committed,

View File

@@ -744,6 +744,8 @@ future<> storage_service::topology_state_load(state_change_hint hint) {
return read_new_t::no;
}
switch (*state) {
case topology::transition_state::lock:
[[fallthrough]];
case topology::transition_state::join_group0:
[[fallthrough]];
case topology::transition_state::tablet_migration:

View File

@@ -2341,6 +2341,10 @@ class topology_coordinator : public endpoint_lifecycle_subscriber {
case topology::transition_state::tablet_resize_finalization:
co_await handle_tablet_resize_finalization(std::move(guard));
break;
case topology::transition_state::lock:
release_guard(std::move(guard));
co_await await_event();
break;
case topology::transition_state::left_token_ring: {
auto node = get_node_to_work_on(std::move(guard));

View File

@@ -153,6 +153,7 @@ static std::unordered_map<topology::transition_state, sstring> transition_state_
{topology::transition_state::left_token_ring, "left token ring"},
{topology::transition_state::rollback_to_normal, "rollback to normal"},
{topology::transition_state::truncate_table, "truncate table"},
{topology::transition_state::lock, "lock"},
};
// Allows old deprecated names to be recognized and point to the correct transition.

View File

@@ -120,6 +120,7 @@ struct topology {
left_token_ring,
rollback_to_normal,
truncate_table,
lock,
};
std::optional<transition_state> tstate;