diff --git a/row_cache.cc b/row_cache.cc index 678ed1aa47..eeeb8b87cc 100644 --- a/row_cache.cc +++ b/row_cache.cc @@ -443,13 +443,14 @@ future<> row_cache::update(memtable& m, partition_presence_checker presence_chec auto t = seastar::thread(attr, [this, &m, presence_checker = std::move(presence_checker)] { auto cleanup = defer([&] { with_allocator(_tracker.allocator(), [&m, this] () { + logalloc::reclaim_lock _(_tracker.region()); bool blow_cache = false; // Note: clear_and_dispose() ought not to look up any keys, so it doesn't require // with_linearized_managed_bytes(), but invalidate() does. m.partitions.clear_and_dispose([this, deleter = current_deleter(), &blow_cache] (partition_entry* entry) { with_linearized_managed_bytes([&] { try { - invalidate(entry->key()); + invalidate_locked(entry->key()); deleter(entry); } catch (...) { blow_cache = true; @@ -541,14 +542,19 @@ void row_cache::touch(const dht::decorated_key& dk) { }); } +void row_cache::invalidate_locked(const dht::decorated_key& dk) { + _partitions.erase_and_dispose(dk, cache_entry::compare(_schema), + [this, deleter = current_deleter()](auto&& p) mutable { + _tracker.on_erase(); + deleter(p); + }); +} + void row_cache::invalidate(const dht::decorated_key& dk) { _read_section(_tracker.region(), [&] { with_allocator(_tracker.allocator(), [this, &dk] { with_linearized_managed_bytes([&] { - _partitions.erase_and_dispose(dk, cache_entry::compare(_schema), [this, deleter = current_deleter()] (auto&& p) mutable { - _tracker.on_erase(); - deleter(p); - }); + invalidate_locked(dk); }); }); }); diff --git a/row_cache.hh b/row_cache.hh index 3790731aa4..2690aa4632 100644 --- a/row_cache.hh +++ b/row_cache.hh @@ -199,6 +199,7 @@ private: void on_hit(); void on_miss(); void upgrade_entry(cache_entry&); + void invalidate_locked(const dht::decorated_key&); static thread_local seastar::thread_scheduling_group _update_thread_scheduling_group; public: ~row_cache();