diff --git a/sstables/sstables_manager.cc b/sstables/sstables_manager.cc index c0f0a6c029..c1a6439712 100644 --- a/sstables/sstables_manager.cc +++ b/sstables/sstables_manager.cc @@ -154,7 +154,10 @@ sstable_writer_config sstables_manager::configure_writer(sstring origin) const { void sstables_manager::increment_total_reclaimable_memory_and_maybe_reclaim(sstable* sst) { _total_reclaimable_memory += sst->total_reclaimable_memory_size(); + maybe_reclaim_components(); +} +void sstables_manager::maybe_reclaim_components() { size_t memory_reclaim_threshold = _available_memory * _db_config.components_memory_reclaim_threshold(); if (_total_reclaimable_memory <= memory_reclaim_threshold) { // total memory used is within limit; no need to reclaim. diff --git a/sstables/sstables_manager.hh b/sstables/sstables_manager.hh index 6342141da9..4e9a0d151f 100644 --- a/sstables/sstables_manager.hh +++ b/sstables/sstables_manager.hh @@ -218,6 +218,8 @@ private: void increment_total_reclaimable_memory_and_maybe_reclaim(sstable* sst); // Fiber to reload reclaimed components back into memory when memory becomes available. future<> components_reloader_fiber(); + // Reclaims components from SSTables if total memory usage exceeds the threshold. + void maybe_reclaim_components(); // Reloads components from reclaimed SSTables if memory is available. future<> maybe_reload_components(); size_t get_memory_available_for_reclaimable_components();