From aa970bf2e485ed8e1d8941fbb61a3d4fbcd52103 Mon Sep 17 00:00:00 2001 From: Petr Gusev Date: Wed, 18 Jun 2025 11:09:30 +0200 Subject: [PATCH] sp::cas_shard: rename to get_cas_shard We intend to introduce a separate cas_shard class in the next commits. We rename the existing function here to avoid conflicts. --- alternator/executor.cc | 6 +++--- cql3/statements/batch_statement.cc | 2 +- cql3/statements/modification_statement.cc | 2 +- service/storage_proxy.cc | 6 +++--- service/storage_proxy.hh | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/alternator/executor.cc b/alternator/executor.cc index fdb724b270..21b9c984c8 100644 --- a/alternator/executor.cc +++ b/alternator/executor.cc @@ -2386,7 +2386,7 @@ rmw_operation::write_isolation rmw_operation::get_write_isolation_for_schema(sch // shard_for_execute() checks whether execute() must be called on a specific // other shard. Running execute() on a specific shard is necessary only if it // will use LWT (storage_proxy::cas()). This is because cas() can only be -// called on the specific shard owning (as per cas_shard()) _pk's token. +// called on the specific shard owning (as per get_cas_shard()) _pk's token. // Knowing if execute() will call cas() or not may depend on whether there is // a read-before-write, but not just on it - depending on configuration, // execute() may unconditionally use cas() for every write. Unfortunately, @@ -2400,7 +2400,7 @@ std::optional rmw_operation::shard_for_execute(bool needs_read_before_ // If we're still here, cas() *will* be called by execute(), so let's // find the appropriate shard to run it on: auto token = dht::get_token(*_schema, _pk); - auto desired_shard = service::storage_proxy::cas_shard(*_schema, token); + auto desired_shard = service::storage_proxy::get_cas_shard(*_schema, token); if (desired_shard == this_shard_id()) { return {}; } @@ -2872,7 +2872,7 @@ static future<> do_batch_write(service::storage_proxy& proxy, } return parallel_for_each(std::move(key_builders), [&proxy, &client_state, &stats, trace_state, ssg, permit = std::move(permit)] (auto& e) { stats.write_using_lwt++; - auto desired_shard = service::storage_proxy::cas_shard(*e.first.schema, e.first.dk.token()); + auto desired_shard = service::storage_proxy::get_cas_shard(*e.first.schema, e.first.dk.token()); if (desired_shard == this_shard_id()) { return cas_write(proxy, e.first.schema, e.first.dk, std::move(e.second), client_state, trace_state, permit); } else { diff --git a/cql3/statements/batch_statement.cc b/cql3/statements/batch_statement.cc index 270de52a54..64eb606161 100644 --- a/cql3/statements/batch_statement.cc +++ b/cql3/statements/batch_statement.cc @@ -367,7 +367,7 @@ future> batch_statement::exe throw exceptions::invalid_request_exception(format("Unrestricted partition key in a conditional BATCH")); } - auto shard = service::storage_proxy::cas_shard(*_statements[0].statement->s, request->key()[0].start()->value().as_decorated_key().token()); + auto shard = service::storage_proxy::get_cas_shard(*_statements[0].statement->s, request->key()[0].start()->value().as_decorated_key().token()); if (shard != this_shard_id()) { return make_ready_future>( qp.bounce_to_shard(shard, std::move(cached_fn_calls)) diff --git a/cql3/statements/modification_statement.cc b/cql3/statements/modification_statement.cc index 1194619133..066cc453ef 100644 --- a/cql3/statements/modification_statement.cc +++ b/cql3/statements/modification_statement.cc @@ -403,7 +403,7 @@ modification_statement::execute_with_condition(query_processor& qp, service::que auto token = request->key()[0].start()->value().as_decorated_key().token(); - auto shard = service::storage_proxy::cas_shard(*s, token); + auto shard = service::storage_proxy::get_cas_shard(*s, token); if (utils::get_local_injector().is_enabled("forced_bounce_to_shard_counter")) { return process_forced_rebounce(shard, qp, options); diff --git a/service/storage_proxy.cc b/service/storage_proxy.cc index 349e9feffa..eebf084975 100644 --- a/service/storage_proxy.cc +++ b/service/storage_proxy.cc @@ -1144,7 +1144,7 @@ const dht::token& end_token(const dht::partition_range& r) { return r.end() ? r.end()->value().token() : max_token; } -unsigned storage_proxy::cas_shard(const schema& s, dht::token token) { +unsigned storage_proxy::get_cas_shard(const schema& s, dht::token token) { return s.table().shard_for_reads(token); } @@ -6365,7 +6365,7 @@ storage_proxy::do_query_with_paxos(schema_ptr s, exceptions::invalid_request_exception("SERIAL/LOCAL_SERIAL consistency may only be requested for one partition at a time")); } - if (cas_shard(*s, partition_ranges[0].start()->value().as_decorated_key().token()) != this_shard_id()) { + if (get_cas_shard(*s, partition_ranges[0].start()->value().as_decorated_key().token()) != this_shard_id()) { return make_exception_future(std::logic_error("storage_proxy::do_query_with_paxos called on a wrong shard")); } // All cas networking operations run with query provided timeout @@ -6468,7 +6468,7 @@ future storage_proxy::cas(schema_ptr schema, shared_ptr reque db::validate_for_cas(cl_for_paxos); db::validate_for_cas_learn(cl_for_learn, schema->ks_name()); - if (cas_shard(*schema, partition_ranges[0].start()->value().as_decorated_key().token()) != this_shard_id()) { + if (get_cas_shard(*schema, partition_ranges[0].start()->value().as_decorated_key().token()) != this_shard_id()) { co_await coroutine::return_exception(std::logic_error("storage_proxy::cas called on a wrong shard")); } diff --git a/service/storage_proxy.hh b/service/storage_proxy.hh index b969bf67c1..acf2302be3 100644 --- a/service/storage_proxy.hh +++ b/service/storage_proxy.hh @@ -735,7 +735,7 @@ public: return _stats_key; } - static unsigned cas_shard(const schema& s, dht::token token); + static unsigned get_cas_shard(const schema& s, dht::token token); future<> await_pending_writes() noexcept { return _pending_writes_phaser.advance_and_await();