lwt: rename metrics to match accepted terminology

Rename inherited metrics cas_propose and cas_commit
to cas_accept and cas_learn respectively.

A while ago we made a decision to stick to widely accepted
terms for Paxos rounds: prepare, accept, learn. The rest
of the code is using these terms, so rename the metrics
to avoid confusion/technical debt.

While at it, rename a few internal methods and functions.

Fixes #6169

Message-Id: <20200414213537.129547-1-kostja@scylladb.com>
This commit is contained in:
Konstantin Osipov
2020-04-15 00:35:37 +03:00
committed by Tomasz Grabiec
parent 20bc93b941
commit 18b9bb57ac
10 changed files with 22 additions and 22 deletions

View File

@@ -804,14 +804,14 @@ void set_column_family(http_context& ctx, routes& r) {
cf::get_cas_propose.set(r, [&ctx] (std::unique_ptr<request> req) {
return map_reduce_cf(ctx, req->param["name"], utils::estimated_histogram(0), [](column_family& cf) {
return cf.get_stats().estimated_cas_propose;
return cf.get_stats().estimated_cas_accept;
},
utils::estimated_histogram_merge, utils_json::estimated_histogram());
});
cf::get_cas_commit.set(r, [&ctx] (std::unique_ptr<request> req) {
return map_reduce_cf(ctx, req->param["name"], utils::estimated_histogram(0), [](column_family& cf) {
return cf.get_stats().estimated_cas_commit;
return cf.get_stats().estimated_cas_learn;
},
utils::estimated_histogram_merge, utils_json::estimated_histogram());
});

View File

@@ -340,7 +340,7 @@ future<shared_ptr<cql_transport::messages::result_message>> batch_statement::exe
const query_options& options,
service::query_state& qs) const {
auto cl_for_commit = options.get_consistency();
auto cl_for_learn = options.get_consistency();
auto cl_for_paxos = options.check_serial_consistency();
seastar::shared_ptr<cas_request> request;
schema_ptr schema;
@@ -386,7 +386,7 @@ future<shared_ptr<cql_transport::messages::result_message>> batch_statement::exe
return proxy.cas(schema, request, request->read_command(), request->key(),
{read_timeout, qs.get_permit(), qs.get_client_state(), qs.get_trace_state()},
cl_for_paxos, cl_for_commit, batch_timeout, cas_timeout).then([this, request] (bool is_applied) {
cl_for_paxos, cl_for_learn, batch_timeout, cas_timeout).then([this, request] (bool is_applied) {
return modification_statement::build_cas_result_set(_metadata, _columns_of_cas_result_set, is_applied, request->rows());
});
}

View File

@@ -322,7 +322,7 @@ modification_statement::execute_without_condition(service::storage_proxy& proxy,
future<::shared_ptr<cql_transport::messages::result_message>>
modification_statement::execute_with_condition(service::storage_proxy& proxy, service::query_state& qs, const query_options& options) const {
auto cl_for_commit = options.get_consistency();
auto cl_for_learn = options.get_consistency();
auto cl_for_paxos = options.check_serial_consistency();
db::timeout_clock::time_point now = db::timeout_clock::now();
const timeout_config& cfg = options.get_timeout_config();
@@ -354,7 +354,7 @@ modification_statement::execute_with_condition(service::storage_proxy& proxy, se
return proxy.cas(s, request, request->read_command(), request->key(),
{read_timeout, qs.get_permit(), qs.get_client_state(), qs.get_trace_state()},
cl_for_paxos, cl_for_commit, statement_timeout, cas_timeout).then([this, request] (bool is_applied) {
cl_for_paxos, cl_for_learn, statement_timeout, cas_timeout).then([this, request] (bool is_applied) {
return build_cas_result_set(_metadata, _columns_of_cas_result_set, is_applied, request->rows());
});
}

View File

@@ -348,13 +348,13 @@ struct table_stats {
utils::timed_rate_moving_average_and_histogram reads{256};
utils::timed_rate_moving_average_and_histogram writes{256};
utils::timed_rate_moving_average_and_histogram cas_prepare{256};
utils::timed_rate_moving_average_and_histogram cas_propose{256};
utils::timed_rate_moving_average_and_histogram cas_commit{256};
utils::timed_rate_moving_average_and_histogram cas_accept{256};
utils::timed_rate_moving_average_and_histogram cas_learn{256};
utils::estimated_histogram estimated_read;
utils::estimated_histogram estimated_write;
utils::estimated_histogram estimated_cas_prepare;
utils::estimated_histogram estimated_cas_propose;
utils::estimated_histogram estimated_cas_commit;
utils::estimated_histogram estimated_cas_accept;
utils::estimated_histogram estimated_cas_learn;
utils::estimated_histogram estimated_sstable_per_read{35};
utils::timed_rate_moving_average_and_histogram tombstone_scanned;
utils::timed_rate_moving_average_and_histogram live_scanned;

View File

@@ -318,7 +318,7 @@ void validate_for_write(consistency_level cl) {
}
// This is the same than validateForWrite really, but we include a slightly different error message for SERIAL/LOCAL_SERIAL
void validate_for_cas_commit(consistency_level cl, const sstring& keyspace) {
void validate_for_cas_learn(consistency_level cl, const sstring& keyspace) {
switch (cl) {
case consistency_level::SERIAL:
case consistency_level::LOCAL_SERIAL:

View File

@@ -58,7 +58,7 @@ bool is_serial_consistency(consistency_level cl);
void validate_for_cas(consistency_level cl);
void validate_for_cas_commit(consistency_level cl, const sstring& keyspace);
void validate_for_cas_learn(consistency_level cl, const sstring& keyspace);
void validate_counter_for_write(const schema& s, consistency_level cl);

View File

@@ -149,9 +149,9 @@ future<bool> paxos_state::accept(tracing::trace_state_ptr tr_state, schema_ptr s
});
}).finally([schema, lc] () mutable {
auto& stats = get_local_storage_proxy().get_db().local().find_column_family(schema).get_stats();
stats.cas_propose.mark(lc.stop().latency());
stats.cas_accept.mark(lc.stop().latency());
if (lc.is_start()) {
stats.estimated_cas_propose.add(lc.latency(), stats.cas_propose.hist.count);
stats.estimated_cas_accept.add(lc.latency(), stats.cas_accept.hist.count);
}
});
}
@@ -194,9 +194,9 @@ future<> paxos_state::learn(schema_ptr schema, proposal decision, clock_type::ti
});
}).finally([schema, lc] () mutable {
auto& stats = get_local_storage_proxy().get_db().local().find_column_family(schema).get_stats();
stats.cas_commit.mark(lc.stop().latency());
stats.cas_learn.mark(lc.stop().latency());
if (lc.is_start()) {
stats.estimated_cas_commit.add(lc.latency(), stats.cas_commit.hist.count);
stats.estimated_cas_learn.add(lc.latency(), stats.cas_learn.hist.count);
}
});
}

View File

@@ -4356,14 +4356,14 @@ storage_proxy::do_query_with_paxos(schema_ptr s,
*/
future<bool> storage_proxy::cas(schema_ptr schema, shared_ptr<cas_request> request, lw_shared_ptr<query::read_command> cmd,
dht::partition_range_vector&& partition_ranges, storage_proxy::coordinator_query_options query_options,
db::consistency_level cl_for_paxos, db::consistency_level cl_for_commit,
db::consistency_level cl_for_paxos, db::consistency_level cl_for_learn,
clock_type::time_point write_timeout, clock_type::time_point cas_timeout) {
assert(partition_ranges.size() == 1);
assert(query::is_single_partition(partition_ranges[0]));
db::validate_for_cas(cl_for_paxos);
db::validate_for_cas_commit(cl_for_commit, schema->ks_name());
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()) {
throw std::logic_error("storage_proxy::cas called on a wrong shard");
@@ -4374,7 +4374,7 @@ future<bool> storage_proxy::cas(schema_ptr schema, shared_ptr<cas_request> reque
handler = seastar::make_shared<paxos_response_handler>(shared_from_this(),
query_options.trace_state, query_options.permit,
partition_ranges[0].start()->value().as_decorated_key(),
schema, cmd, cl_for_paxos, cl_for_commit, write_timeout, cas_timeout);
schema, cmd, cl_for_paxos, cl_for_learn, write_timeout, cas_timeout);
} catch (exceptions::unavailable_exception& ex) {
get_stats().cas_write_unavailables.mark();
throw;

View File

@@ -562,7 +562,7 @@ public:
future<bool> cas(schema_ptr schema, shared_ptr<cas_request> request, lw_shared_ptr<query::read_command> cmd,
dht::partition_range_vector&& partition_ranges, coordinator_query_options query_options,
db::consistency_level cl_for_paxos, db::consistency_level cl_for_commit,
db::consistency_level cl_for_paxos, db::consistency_level cl_for_learn,
clock_type::time_point write_timeout, clock_type::time_point cas_timeout);
future<> stop();

View File

@@ -1137,8 +1137,8 @@ void table::set_metrics() {
ms::make_histogram("read_latency", ms::description("Read latency histogram"), [this] {return _stats.estimated_read.get_histogram(std::chrono::microseconds(100));})(cf)(ks),
ms::make_histogram("write_latency", ms::description("Write latency histogram"), [this] {return _stats.estimated_write.get_histogram(std::chrono::microseconds(100));})(cf)(ks),
ms::make_histogram("cas_prepare_latency", ms::description("CAS prepare round latency histogram"), [this] {return _stats.estimated_cas_prepare.get_histogram(std::chrono::microseconds(100));})(cf)(ks),
ms::make_histogram("cas_propose_latency", ms::description("CAS propose round latency histogram"), [this] {return _stats.estimated_cas_propose.get_histogram(std::chrono::microseconds(100));})(cf)(ks),
ms::make_histogram("cas_commit_latency", ms::description("CAS commit round latency histogram"), [this] {return _stats.estimated_cas_commit.get_histogram(std::chrono::microseconds(100));})(cf)(ks),
ms::make_histogram("cas_propose_latency", ms::description("CAS accept round latency histogram"), [this] {return _stats.estimated_cas_accept.get_histogram(std::chrono::microseconds(100));})(cf)(ks),
ms::make_histogram("cas_commit_latency", ms::description("CAS learn round latency histogram"), [this] {return _stats.estimated_cas_learn.get_histogram(std::chrono::microseconds(100));})(cf)(ks),
ms::make_gauge("cache_hit_rate", ms::description("Cache hit rate"), [this] {return float(_global_cache_hit_rate);})(cf)(ks)
});
}