Skip to content

Commit 50dac90

Browse files
committed
fixed bug where bg thread gets stuck on failure + compile error
1 parent 6b932f8 commit 50dac90

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

cachelib/allocator/CacheAllocator.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,6 +1777,9 @@ class CacheAllocator : public CacheBase {
17771777
while (evictions < batch && itr) {
17781778

17791779
Item* candidate = itr.get();
1780+
if (candidate == NULL) {
1781+
break;
1782+
}
17801783
// for chained items, the ownership of the parent can change. We try to
17811784
// evict what we think as parent and see if the eviction of parent
17821785
// recycles the child we intend to.
@@ -1820,14 +1823,13 @@ class CacheAllocator : public CacheBase {
18201823
releaseBackToAllocator(itemToRelease, RemoveContext::kEviction,
18211824
/* isNascent */ movedToNextTier, candidate);
18221825

1826+
} else {
1827+
//evict failed - let's quit with what we have
1828+
break;
18231829
}
18241830

1825-
// If we destroyed the itr to possibly evict and failed, we restart
1826-
// from the beginning again
1827-
if (!itr) {
1828-
itr.resetToBegin();
1829-
}
18301831
}
1832+
18311833
// Invalidate iterator since later on we may use this mmContainer
18321834
// again, which cannot be done unless we drop this iterator
18331835
itr.destroy();

cachelib/allocator/CacheAllocatorConfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "cachelib/allocator/NvmAdmissionPolicy.h"
3232
#include "cachelib/allocator/PoolOptimizeStrategy.h"
3333
#include "cachelib/allocator/RebalanceStrategy.h"
34+
#include "cachelib/allocator/BackgroundEvictorStrategy.h"
3435
#include "cachelib/allocator/Util.h"
3536
#include "cachelib/common/EventInterface.h"
3637
#include "cachelib/common/Throttler.h"

0 commit comments

Comments
 (0)