Skip to content

Commit

Permalink
internal queries: add caching to some queries
Browse files Browse the repository at this point in the history
Some of the internal queries didn't have caching enabled even though
there are chances of the query executing in large bursts or relatively
often, example of the former is `default_authorized::authorize` and for
the later is `system_distributed_keyspace::get_service_levels`.

Fixes scylladb#10335

Signed-off-by: Eliran Sinvani <[email protected]>
  • Loading branch information
Eliran Sinvani committed May 1, 2022
1 parent e0c7178 commit a16b4e4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion auth/default_authorizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ default_authorizer::authorize(const role_or_anonymous& maybe_role, const resourc
query,
db::consistency_level::LOCAL_ONE,
{*maybe_role.name, r.name()},
cql3::query_processor::cache_internal::no).then([](::shared_ptr<cql3::untyped_result_set> results) {
cql3::query_processor::cache_internal::yes).then([](::shared_ptr<cql3::untyped_result_set> results) {
if (results->empty()) {
return permissions::NONE;
}
Expand Down
2 changes: 1 addition & 1 deletion auth/standard_role_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ future<role_set> standard_role_manager::query_all() {
query,
db::consistency_level::QUORUM,
internal_distributed_query_state(),
cql3::query_processor::cache_internal::no).then([](::shared_ptr<cql3::untyped_result_set> results) {
cql3::query_processor::cache_internal::yes).then([](::shared_ptr<cql3::untyped_result_set> results) {
role_set roles;

std::transform(
Expand Down
2 changes: 1 addition & 1 deletion db/schema_tables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3343,7 +3343,7 @@ future<bool> column_mapping_exists(utils::UUID table_id, table_schema_version ve
GET_COLUMN_MAPPING_QUERY,
db::consistency_level::LOCAL_ONE,
{table_id, version},
cql3::query_processor::cache_internal::no
cql3::query_processor::cache_internal::yes
);
co_return !results->empty();
}
Expand Down
4 changes: 2 additions & 2 deletions db/system_distributed_keyspace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ static qos::service_level_options::timeout_type get_duration(const cql3::untyped
future<qos::service_levels_info> system_distributed_keyspace::get_service_levels() const {
static sstring prepared_query = format("SELECT * FROM {}.{};", NAME, SERVICE_LEVELS);

return _qp.execute_internal(prepared_query, db::consistency_level::ONE, internal_distributed_query_state(), {}).then([] (shared_ptr<cql3::untyped_result_set> result_set) {
return _qp.execute_internal(prepared_query, db::consistency_level::ONE, internal_distributed_query_state(), cql3::query_processor::cache_internal::yes).then([] (shared_ptr<cql3::untyped_result_set> result_set) {
qos::service_levels_info service_levels;
for (auto &&row : *result_set) {
try {
Expand All @@ -824,7 +824,7 @@ future<qos::service_levels_info> system_distributed_keyspace::get_service_levels

future<qos::service_levels_info> system_distributed_keyspace::get_service_level(sstring service_level_name) const {
static sstring prepared_query = format("SELECT * FROM {}.{} WHERE service_level = ?;", NAME, SERVICE_LEVELS);
return _qp.execute_internal(prepared_query, db::consistency_level::ONE, internal_distributed_query_state(), {service_level_name}, cql3::query_processor::cache_internal::no).then(
return _qp.execute_internal(prepared_query, db::consistency_level::ONE, internal_distributed_query_state(), {service_level_name}, cql3::query_processor::cache_internal::yes).then(
[service_level_name = std::move(service_level_name)] (shared_ptr<cql3::untyped_result_set> result_set) {
qos::service_levels_info service_levels;
if (!result_set->empty()) {
Expand Down

0 comments on commit a16b4e4

Please sign in to comment.