truncate: add truncate_table transition state

Truncate table for tablets is implemented as a global topology operation.
However, it does not have a transition state associated with it, and
performs the truncate logic in handle_global_request() while
topology::tstate remains empty. This creates problems because
topology::is_busy() uses transition_state to determine if the topology
state machine is busy, and will return false even though a truncate
operation is ongoing.

This change adds a new transition state: truncate_table
This commit is contained in:
Ferenc Szili
2025-01-22 10:21:59 +01:00
parent a8805c4fc1
commit 29ead7014e
4 changed files with 6 additions and 0 deletions

View File

@@ -746,6 +746,8 @@ future<> storage_service::topology_state_load(state_change_hint hint) {
[[fallthrough]];
case topology::transition_state::left_token_ring:
[[fallthrough]];
case topology::transition_state::truncate_table:
[[fallthrough]];
case topology::transition_state::rollback_to_normal:
return read_new_t::no;
case topology::transition_state::write_both_read_new:

View File

@@ -2462,6 +2462,8 @@ class topology_coordinator : public endpoint_lifecycle_subscriber {
co_await update_topology_state(std::move(node.guard), {builder.build(), rtbuilder.build()}, str);
}
break;
case topology::transition_state::truncate_table:
break;
}
co_return true;
};

View File

@@ -152,6 +152,7 @@ static std::unordered_map<topology::transition_state, sstring> transition_state_
{topology::transition_state::tablet_draining, "tablet draining"},
{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"},
};
// Allows old deprecated names to be recognized and point to the correct transition.

View File

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