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")) {