From f4f757af23b4e21baaaa76b97dbd1d25e1bfb952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Botond=20D=C3=A9nes?= Date: Fri, 12 May 2023 06:58:18 -0400 Subject: [PATCH] db/system_keyspace: replace storage_proxy::query*() with replica:: equivalent Use the recently introduced replica side query utility functions to query the content of the system tables. This allows us to cut the dependency of the system keyspace on storage proxy. The methods still take storage proxy parameter, this will be replaced with replica::database in the next patch. There is still one hidden storage proxy dependency left, via clq3::query_processor. This will be addressed later. --- db/system_keyspace.cc | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/db/system_keyspace.cc b/db/system_keyspace.cc index bf443568eb..38806d61c0 100644 --- a/db/system_keyspace.cc +++ b/db/system_keyspace.cc @@ -69,6 +69,7 @@ #include "sstables/generation_type.hh" #include "cdc/generation.hh" #include "replica/tablets.hh" +#include "replica/query.hh" using days = std::chrono::duration>; @@ -3010,33 +3011,25 @@ future>> system_keyspace::query_mutations(distributed& proxy, const sstring& ks_name, const sstring& cf_name) { replica::database& db = proxy.local().get_db().local(); schema_ptr schema = db.find_schema(ks_name, cf_name); - auto slice = partition_slice_builder(*schema).build(); - auto cmd = make_lw_shared(schema->id(), schema->version(), std::move(slice), proxy.local().get_max_result_size(slice), query::tombstone_limit::max); - return proxy.local().query_mutations_locally(std::move(schema), std::move(cmd), query::full_partition_range, db::no_timeout) - .then([] (rpc::tuple>, cache_temperature> rr_ht) { return std::get<0>(std::move(rr_ht)); }); + return replica::query_mutations(proxy.local().get_db(), schema, query::full_partition_range, schema->full_slice(), db::no_timeout); } future>> system_keyspace::query_mutations(distributed& proxy, const sstring& ks_name, const sstring& cf_name, const dht::partition_range& partition_range, query::clustering_range row_range) { auto& db = proxy.local().get_db().local(); auto schema = db.find_schema(ks_name, cf_name); - auto slice = partition_slice_builder(*schema) + auto slice_ptr = std::make_unique(partition_slice_builder(*schema) .with_range(std::move(row_range)) - .build(); - auto cmd = make_lw_shared(schema->id(), schema->version(), std::move(slice), proxy.local().get_max_result_size(slice), query::tombstone_limit::max); - return proxy.local().query_mutations_locally(std::move(schema), std::move(cmd), partition_range, db::no_timeout) - .then([] (rpc::tuple>, cache_temperature> rr_ht) { return std::get<0>(std::move(rr_ht)); }); + .build()); + return replica::query_mutations(proxy.local().get_db(), std::move(schema), partition_range, *slice_ptr, db::no_timeout).finally([slice_ptr = std::move(slice_ptr)] { }); } future> system_keyspace::query(distributed& proxy, const sstring& ks_name, const sstring& cf_name) { replica::database& db = proxy.local().get_db().local(); schema_ptr schema = db.find_schema(ks_name, cf_name); - auto slice = partition_slice_builder(*schema).build(); - auto cmd = make_lw_shared(schema->id(), schema->version(), std::move(slice), proxy.local().get_max_result_size(slice), query::tombstone_limit::max); - return proxy.local().query(schema, cmd, {query::full_partition_range}, db::consistency_level::ONE, - {db::no_timeout, empty_service_permit(), service::client_state::for_internal_calls(), nullptr}).then([schema, cmd] (auto&& qr) { - return make_lw_shared(query::result_set::from_raw_result(schema, cmd->slice, *qr.query_result)); + return replica::query_data(proxy.local().get_db(), schema, query::full_partition_range, schema->full_slice(), db::no_timeout).then([schema] (auto&& qr) { + return make_lw_shared(query::result_set::from_raw_result(schema, schema->full_slice(), *qr)); }); } @@ -3045,14 +3038,13 @@ system_keyspace::query(distributed& proxy, const sstring { auto&& db = proxy.local().get_db().local(); auto schema = db.find_schema(ks_name, cf_name); - auto slice = partition_slice_builder(*schema) + auto pr_ptr = std::make_unique(dht::partition_range::make_singular(key)); + auto slice_ptr = std::make_unique(partition_slice_builder(*schema) .with_range(std::move(row_range)) - .build(); - auto cmd = make_lw_shared(schema->id(), schema->version(), std::move(slice), proxy.local().get_max_result_size(slice), query::tombstone_limit::max); - - return proxy.local().query(schema, cmd, {dht::partition_range::make_singular(key)}, db::consistency_level::ONE, - {db::no_timeout, empty_service_permit(), service::client_state::for_internal_calls(), nullptr}).then([schema, cmd] (auto&& qr) { - return make_lw_shared(query::result_set::from_raw_result(schema, cmd->slice, *qr.query_result)); + .build()); + return replica::query_data(proxy.local().get_db(), schema, *pr_ptr, *slice_ptr, db::no_timeout).then( + [schema, pr_ptr = std::move(pr_ptr), slice_ptr = std::move(slice_ptr)] (auto&& qr) { + return make_lw_shared(query::result_set::from_raw_result(schema, schema->full_slice(), *qr)); }); }