From 97af6bb0bdf663d92a89be36dd4037bac7dce20e Mon Sep 17 00:00:00 2001 From: Gleb Natapov Date: Sun, 19 Apr 2020 10:40:38 +0300 Subject: [PATCH] lwt: make load_paxos_state to take partition_key_view instead of a deference Some caller have partition_key_view, but not partition_key, so thy need to create a temporary and copy just to pass a reference. Change it by accepting a view. --- db/system_keyspace.cc | 4 ++-- db/system_keyspace.hh | 2 +- service/paxos/paxos_state.cc | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/db/system_keyspace.cc b/db/system_keyspace.cc index 568b5d8338..c201b7dbfc 100644 --- a/db/system_keyspace.cc +++ b/db/system_keyspace.cc @@ -2190,13 +2190,13 @@ future> load_view_build_progress() { }); } -future load_paxos_state(const partition_key& key, schema_ptr s, gc_clock::time_point now, +future load_paxos_state(partition_key_view key, schema_ptr s, gc_clock::time_point now, db::timeout_clock::time_point timeout) { static auto cql = format("SELECT * FROM system.{} WHERE row_key = ? AND cf_id = ?", PAXOS); // FIXME: we need execute_cql_with_now() (void)now; auto f = execute_cql_with_timeout(cql, timeout, to_legacy(*key.get_compound_type(*s), key.representation()), s->id()); - return f.then([s, key] (shared_ptr results) mutable { + return f.then([s, key = std::move(key)] (shared_ptr results) mutable { if (results->empty()) { return service::paxos::paxos_state(); } diff --git a/db/system_keyspace.hh b/db/system_keyspace.hh index 21e3900215..b92e5f9134 100644 --- a/db/system_keyspace.hh +++ b/db/system_keyspace.hh @@ -642,7 +642,7 @@ future> load_built_views(); future> load_view_build_progress(); // Paxos related functions -future load_paxos_state(const partition_key& key, schema_ptr s, gc_clock::time_point now, +future load_paxos_state(partition_key_view key, schema_ptr s, gc_clock::time_point now, db::timeout_clock::time_point timeout); future<> save_paxos_promise(const schema& s, const partition_key& key, const utils::UUID& ballot, db::timeout_clock::time_point timeout); future<> save_paxos_proposal(const schema& s, const service::paxos::proposal& proposal, db::timeout_clock::time_point timeout); diff --git a/service/paxos/paxos_state.cc b/service/paxos/paxos_state.cc index 61ac9f5a0d..df0ed68cb3 100644 --- a/service/paxos/paxos_state.cc +++ b/service/paxos/paxos_state.cc @@ -127,8 +127,7 @@ future paxos_state::accept(tracing::trace_state_ptr tr_state, schema_ptr s return with_locked_key(token, timeout, [&proposal, schema, tr_state, timeout] () mutable { auto now_in_sec = utils::UUID_gen::unix_timestamp_in_sec(proposal.ballot); - auto f = db::system_keyspace::load_paxos_state(proposal.update.decorated_key(*schema).key(), schema, - gc_clock::time_point(now_in_sec), timeout); + auto f = db::system_keyspace::load_paxos_state(proposal.update.key(), schema, gc_clock::time_point(now_in_sec), timeout); return f.then([&proposal, tr_state, schema, timeout] (paxos_state state) { return utils::get_local_injector().inject("paxos_state_accept_timeout", timeout).then( [&proposal, state = std::move(state), tr_state, schema, timeout] {