This is an automated email from the ASF dual-hosted git repository. williamsong pushed a commit to branch snapshot-3 in repository https://gitbox.apache.org/repos/asf/ratis.git
commit 5baff19fffa768f2c2cabcd26842f06534262191 Author: Duong Nguyen <[email protected]> AuthorDate: Sat Jan 27 13:10:03 2024 -0800 RATIS-2017: checkAndEvictCache must be done in writeLock. (#1031) --- .../ratis/server/raftlog/segmented/SegmentedRaftLog.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLog.java b/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLog.java index a729f8e2e..4936525cb 100644 --- a/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLog.java +++ b/ratis-server/src/main/java/org/apache/ratis/server/raftlog/segmented/SegmentedRaftLog.java @@ -324,11 +324,13 @@ public final class SegmentedRaftLog extends RaftLogBase { private void checkAndEvictCache() { if (cache.shouldEvict()) { - // TODO if the cache is hitting the maximum size and we cannot evict any - // segment's cache, should block the new entry appending or new segment - // allocation. - cache.evictCache(server.getFollowerNextIndices(), fileLogWorker.getSafeCacheEvictIndex(), - server.getLastAppliedIndex()); + try (AutoCloseableLock ignored = writeLock()){ + // TODO if the cache is hitting the maximum size and we cannot evict any + // segment's cache, should block the new entry appending or new segment + // allocation. + cache.evictCache(server.getFollowerNextIndices(), fileLogWorker.getSafeCacheEvictIndex(), + server.getLastAppliedIndex()); + } } }
