From 29ead7014e3cd52ddd4a46cd26c02dab2f2b4068 Mon Sep 17 00:00:00 2001 From: Ferenc Szili Date: Wed, 22 Jan 2025 10:21:59 +0100 Subject: [PATCH] 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 --- service/storage_service.cc | 2 ++ service/topology_coordinator.cc | 2 ++ service/topology_state_machine.cc | 1 + service/topology_state_machine.hh | 1 + 4 files changed, 6 insertions(+) diff --git a/service/storage_service.cc b/service/storage_service.cc index 5c738e304b..98782ad7dd 100644 --- a/service/storage_service.cc +++ b/service/storage_service.cc @@ -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: diff --git a/service/topology_coordinator.cc b/service/topology_coordinator.cc index e5200f30d1..cf5dd71f56 100644 --- a/service/topology_coordinator.cc +++ b/service/topology_coordinator.cc @@ -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; }; diff --git a/service/topology_state_machine.cc b/service/topology_state_machine.cc index fd31e5a538..190ffaab66 100644 --- a/service/topology_state_machine.cc +++ b/service/topology_state_machine.cc @@ -152,6 +152,7 @@ static std::unordered_map 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. diff --git a/service/topology_state_machine.hh b/service/topology_state_machine.hh index 23db2af0a4..8e7014c8ff 100644 --- a/service/topology_state_machine.hh +++ b/service/topology_state_machine.hh @@ -119,6 +119,7 @@ struct topology { tablet_resize_finalization, left_token_ring, rollback_to_normal, + truncate_table, }; std::optional tstate;