diff --git a/querier.cc b/querier.cc index 8416149961..1db2a5a6fd 100644 --- a/querier.cc +++ b/querier.cc @@ -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 {}.{} {} (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; } diff --git a/querier.hh b/querier.hh index 6fa4090de2..6a65420aab 100644 --- a/querier.hh +++ b/querier.hh @@ -147,6 +147,9 @@ public: class querier : public querier_base { lw_shared_ptr _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 {}.{} {} (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); }); }