From 064ac25ff91fbc1db4bcdf67716b0dbeea3bd1bc Mon Sep 17 00:00:00 2001 From: Michael Litvak Date: Wed, 26 Mar 2025 13:26:28 +0200 Subject: [PATCH] tablets: read_tablet_transition_stage: read from base table When reading tablet information from system.tablets we need to read it from the base table, if exists. --- replica/tablets.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/replica/tablets.cc b/replica/tablets.cc index debd9d8c01..9704456037 100644 --- a/replica/tablets.cc +++ b/replica/tablets.cc @@ -910,7 +910,20 @@ lw_shared_ptr make_tablet_sstable_set(schema_ptr s, const return tablet_sstable_set::make(std::move(s), sgm, tmap); } +future> read_base_table(cql3::query_processor& qp, table_id tid) { + auto rs = co_await qp.execute_internal("select * from system.tablets where table_id = ?", + {tid.uuid()}, cql3::query_processor::cache_internal::no); + if (rs->empty() || !rs->front().has("base_table")) { + co_return std::nullopt; + } + + co_return table_id(rs->front().get_as("base_table")); +} + future> read_tablet_transition_stage(cql3::query_processor& qp, table_id tid, dht::token last_token) { + if (auto base_table = co_await read_base_table(qp, tid)) { + tid = *base_table; + } auto rs = co_await qp.execute_internal("select stage from system.tablets where table_id = ? and last_token = ?", {tid.uuid(), dht::token::to_int64(last_token)}, cql3::query_processor::cache_internal::no); if (rs->empty() || !rs->one().has("stage")) {