mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-20 00:20:47 +00:00
cdc: add an object for tracking progress of cdc mutations
CDC metrics, apart from tracking "total" metrics for all performed CDC operations, also track metrics for "failed" operations. Because the result of the CDC operation depends on whether all CDC mutations were written successfully by storage_proxy, checking for failure and incrementing appropriate counters is deferred after all write response handlers finish. The `cdc::operation_result_tracker` object was created for that purpose. It contains all the details needed to accurately update the metrics based on what actually happened in the `augment_mutation_call` function, and holds a flag which tells if any of write response handlers failed. This object is supposed to be referenced by write response handlers for CDC mutations created after the same `augment_mutation_call`. After all write response handlers are destroyed, the destructor of `operation_result_tracker` will update appropriate metrics. Actual creating and attaching this object to write response handlers will be done in subsequent commits.
This commit is contained in:
22
cdc/log.cc
22
cdc/log.cc
@@ -126,6 +126,28 @@ cdc::stats::stats() {
|
||||
register_counters(counters_failed, "failed");
|
||||
}
|
||||
|
||||
cdc::operation_result_tracker::~operation_result_tracker() {
|
||||
auto update_stats = [this] (stats::counters& counters) {
|
||||
if (_details.was_split) {
|
||||
counters.split_count++;
|
||||
} else {
|
||||
counters.unsplit_count++;
|
||||
}
|
||||
counters.touches.apply(_details.touched_parts);
|
||||
if (_details.had_preimage) {
|
||||
counters.with_preimage_count++;
|
||||
}
|
||||
if (_details.had_postimage) {
|
||||
counters.with_postimage_count++;
|
||||
}
|
||||
};
|
||||
|
||||
update_stats(_stats.counters_total);
|
||||
if (_failed) {
|
||||
update_stats(_stats.counters_failed);
|
||||
}
|
||||
}
|
||||
|
||||
class cdc::cdc_service::impl : service::migration_listener::empty_listener {
|
||||
friend cdc_service;
|
||||
db_context _ctxt;
|
||||
|
||||
28
cdc/stats.hh
28
cdc/stats.hh
@@ -89,4 +89,32 @@ public:
|
||||
stats();
|
||||
};
|
||||
|
||||
// Contains the details on what happened during a CDC operation.
|
||||
struct operation_details final {
|
||||
stats::part_type_set touched_parts;
|
||||
bool was_split = false;
|
||||
bool had_preimage = false;
|
||||
bool had_postimage = false;
|
||||
};
|
||||
|
||||
// This object tracks the lifetime of write handlers related to one CDC operation. After all
|
||||
// write handlers for the operation finish, CDC metrics are updated.
|
||||
class operation_result_tracker final {
|
||||
stats& _stats;
|
||||
operation_details _details;
|
||||
bool _failed;
|
||||
|
||||
public:
|
||||
operation_result_tracker(stats& stats, operation_details details)
|
||||
: _stats(stats)
|
||||
, _details(details)
|
||||
, _failed(false)
|
||||
{}
|
||||
~operation_result_tracker();
|
||||
|
||||
void on_mutation_failed() {
|
||||
_failed = true;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user