Join GitHub today
std::bad_alloc may be thrown even though there is evictable memory #4445
Scylla version: 2.3+ (252c5df)
When we start the LSA reclamation it can be that segment_pool::_free_segments is 0 under some conditions and segment_pool::_current_emergency_reserve_goal is set to 1. The reclamation step is 1 segment, and compact_and_evict_locked() frees 1 segment into the segment_pool. However, segment_pool::reclaim_segments() doesn't free anything to the standard allocator, because the condition _free_segments > _current_emergency_reserve_goal is false. As a result, tracker::impl::reclaim() returns 0 as the amount of released memory, and tracker::reclaim() returns memory::reclaiming_result::reclaimed_nothing, and the seastar allocator thinks it's a real OOM and throws
We should take the reserve goal into account when deciding on how much to release.