From 5da01297752522d57a7ea68a628453ea5da29b90 Mon Sep 17 00:00:00 2001 From: Calle Wilund Date: Wed, 3 Mar 2021 15:44:54 +0000 Subject: [PATCH] system_distributed_keyspace: Add better routine to get latest cdc gen. timestamp Since we have a table of cdc version timestamps, conviniently sorted reversed, we can just query this and get the latest known gen ts. --- db/system_distributed_keyspace.cc | 12 ++++++++++++ db/system_distributed_keyspace.hh | 3 +++ 2 files changed, 15 insertions(+) diff --git a/db/system_distributed_keyspace.cc b/db/system_distributed_keyspace.cc index f872a7f099..f037ac1078 100644 --- a/db/system_distributed_keyspace.cc +++ b/db/system_distributed_keyspace.cc @@ -525,6 +525,18 @@ system_distributed_keyspace::cdc_get_versioned_streams(db_clock::time_point not_ co_return result; } +future +system_distributed_keyspace::cdc_current_generation_timestamp(context ctx) { + auto timestamp_cql = co_await _qp.execute_internal( + format("SELECT time FROM {}.{} WHERE key = ? limit 1", NAME, CDC_TIMESTAMPS), + quorum_if_many(ctx.num_token_owners), + internal_distributed_query_state(), + { CDC_TIMESTAMPS_KEY }, + false); + + co_return timestamp_cql->one().get_as("time"); +} + future> system_distributed_keyspace::get_cdc_desc_v1_timestamps(context ctx) { std::vector res; diff --git a/db/system_distributed_keyspace.hh b/db/system_distributed_keyspace.hh index cf434749d5..7be342df60 100644 --- a/db/system_distributed_keyspace.hh +++ b/db/system_distributed_keyspace.hh @@ -109,6 +109,9 @@ public: future> get_cdc_desc_v1_timestamps(context); future> cdc_get_versioned_streams(db_clock::time_point not_older_than, context); + + future cdc_current_generation_timestamp(context); + }; }