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.
This commit is contained in:
Calle Wilund
2021-03-03 15:44:54 +00:00
parent 5a69250d7e
commit 5da0129775
2 changed files with 15 additions and 0 deletions

View File

@@ -525,6 +525,18 @@ system_distributed_keyspace::cdc_get_versioned_streams(db_clock::time_point not_
co_return result;
}
future<db_clock::time_point>
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<db_clock::time_point>("time");
}
future<std::vector<db_clock::time_point>>
system_distributed_keyspace::get_cdc_desc_v1_timestamps(context ctx) {
std::vector<db_clock::time_point> res;

View File

@@ -109,6 +109,9 @@ public:
future<std::vector<db_clock::time_point>> get_cdc_desc_v1_timestamps(context);
future<std::map<db_clock::time_point, cdc::streams_version>> cdc_get_versioned_streams(db_clock::time_point not_older_than, context);
future<db_clock::time_point> cdc_current_generation_timestamp(context);
};
}