Skip to content

Commit 24db3e3

Browse files
committed
Fix ReaperSkippingSlabTraversalWhileSlabReleasing test
The issue was caused by incorrect behaviour of the CacheAllocator<CacheTrait>::tryEvictToNextMemoryTier method in case the evicted item is expired. We cannot simply return a handle to it, but we need to remove it from the access container and MM container.
1 parent a4c4ab3 commit 24db3e3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

cachelib/allocator/CacheAllocator-inl.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,16 @@ typename CacheAllocator<CacheTrait>::WriteHandle
16411641
CacheAllocator<CacheTrait>::tryEvictToNextMemoryTier(
16421642
TierId tid, PoolId pid, Item& item) {
16431643
if(item.isChainedItem()) return {}; // TODO: We do not support ChainedItem yet
1644-
if(item.isExpired()) return acquire(&item);
1644+
if(item.isExpired()) {
1645+
auto handle = accessContainer_->removeIf(item,
1646+
[](const Item& it) {
1647+
return it.getRefCount() == 0;
1648+
});
1649+
if(handle) {
1650+
removeFromMMContainer(item);
1651+
}
1652+
return handle;
1653+
}
16451654

16461655
TierId nextTier = tid; // TODO - calculate this based on some admission policy
16471656
while (++nextTier < getNumTiers()) { // try to evict down to the next memory tiers

0 commit comments

Comments
 (0)