querier: consume_page(): extract code which logs tombstone warning

Soon, we want to log a warning on too many cell tombstones as well.
Extract the logging code to allow reuse between the row and cell
tombstone warnings.
This commit is contained in:
Botond Dénes
2024-05-28 10:37:44 -04:00
parent e403644c8b
commit fa2ee6d545
2 changed files with 20 additions and 11 deletions

View File

@@ -443,6 +443,19 @@ future<> querier_base::close() noexcept {
return std::visit(variant_closer{*this}, _reader);
}
void querier::maybe_log_tombstone_warning(std::string_view what, uint64_t live, uint64_t dead) {
if (!_qr_config.tombstone_warn_threshold || dead < _qr_config.tombstone_warn_threshold) {
return;
}
if (_range->is_singular()) {
qrlogger.warn("Read {} live {} and {} dead {}/tombstones for {}.{} partition key \"{}\" {} (see tombstone_warn_threshold)",
live, what, dead, what, _schema->ks_name(), _schema->cf_name(), _range->start()->value().key()->with_schema(*_schema), (*_range));
} else {
qrlogger.warn("Read {} live {} and {} dead {}/tombstones for {}.{} <partition-range-scan> {} (see tombstone_warn_threshold)",
live, what, dead, what, _schema->ks_name(), _schema->cf_name(), (*_range));
}
}
void querier_cache::set_entry_ttl(std::chrono::seconds entry_ttl) {
_entry_ttl = entry_ttl;
}

View File

@@ -147,6 +147,9 @@ public:
class querier : public querier_base {
lw_shared_ptr<compact_for_query_state_v2> _compaction_state;
private:
void maybe_log_tombstone_warning(std::string_view what, uint64_t live, uint64_t dead);
public:
querier(const mutation_source& ms,
schema_ptr schema,
@@ -182,17 +185,10 @@ public:
cstats.clustering_rows.live,
cstats.clustering_rows.dead,
cstats.range_tombstones);
auto dead = cstats.static_rows.dead + cstats.clustering_rows.dead + cstats.range_tombstones;
if (_qr_config.tombstone_warn_threshold > 0 && dead >= _qr_config.tombstone_warn_threshold) {
auto live = cstats.static_rows.live + cstats.clustering_rows.live;
if (_range->is_singular()) {
qrlogger.warn("Read {} live rows and {} tombstones for {}.{} partition key \"{}\" {} (see tombstone_warn_threshold)",
live, dead, _schema->ks_name(), _schema->cf_name(), _range->start()->value().key()->with_schema(*_schema), (*_range));
} else {
qrlogger.warn("Read {} live rows and {} tombstones for {}.{} <partition-range-scan> {} (see tombstone_warn_threshold)",
live, dead, _schema->ks_name(), _schema->cf_name(), (*_range));
}
}
maybe_log_tombstone_warning(
"rows",
cstats.static_rows.live + cstats.clustering_rows.live,
cstats.static_rows.dead + cstats.clustering_rows.dead + cstats.range_tombstones);
return std::move(fut);
});
}