replica/memtable: add tombstone_gc_state_snapshot

To be used for possibly excluding the memtable from overlap checks with
the cache/sstables, in memtable_list::get_max_purgeable().
This commit is contained in:
Botond Dénes
2025-07-17 17:21:28 +03:00
parent ab633590f1
commit ef8a21b4cf
2 changed files with 14 additions and 2 deletions

View File

@@ -121,7 +121,9 @@ void memtable::memtable_encoding_stats_collector::update(const ::schema& s, cons
memtable::memtable(schema_ptr schema, dirty_memory_manager& dmm,
memtable_table_shared_data& table_shared_data,
replica::table_stats& table_stats,
memtable_list* memtable_list, seastar::scheduling_group compaction_scheduling_group)
memtable_list* memtable_list,
seastar::scheduling_group compaction_scheduling_group,
shared_tombstone_gc_state* shared_gc_state)
: dirty_memory_manager_logalloc::size_tracked_region()
, _dirty_mgr(dmm)
, _cleaner(*this, no_cache_tracker, table_stats.memtable_app_stats, compaction_scheduling_group)
@@ -130,6 +132,9 @@ memtable::memtable(schema_ptr schema, dirty_memory_manager& dmm,
, _table_shared_data(table_shared_data)
, partitions(dht::raw_token_less_comparator{})
, _table_stats(table_stats) {
if (shared_gc_state) {
_tombstone_gc_snapshot.emplace(shared_gc_state->snapshot());
}
logalloc::region::listen(this);
}

View File

@@ -202,6 +202,8 @@ private:
}
} _stats_collector;
std::optional<tombstone_gc_state_snapshot> _tombstone_gc_snapshot;
void update(db::rp_handle&&);
friend class ::row_cache;
friend class memtable_entry;
@@ -220,7 +222,8 @@ public:
explicit memtable(schema_ptr schema, dirty_memory_manager&,
memtable_table_shared_data& shared_data,
replica::table_stats& table_stats, memtable_list *memtable_list = nullptr,
seastar::scheduling_group compaction_scheduling_group = seastar::current_scheduling_group());
seastar::scheduling_group compaction_scheduling_group = seastar::current_scheduling_group(),
shared_tombstone_gc_state* shared_gc_state = nullptr);
// Used for testing that want to control the flush process.
explicit memtable(schema_ptr schema);
~memtable();
@@ -348,6 +351,10 @@ public:
return _dirty_mgr;
}
const tombstone_gc_state_snapshot* get_tombstone_gc_state_snapshot() const noexcept {
return _tombstone_gc_snapshot ? &_tombstone_gc_snapshot.value() : nullptr;
}
// Implementation of region_listener.
virtual void increase_usage(logalloc::region* r, ssize_t delta) override;
virtual void decrease_evictable_usage(logalloc::region* r) override;