You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by sz...@apache.org on 2026/10/14 18:00:58 UTC

(ratis) branch master updated: RATIS-2746. Flaky org.apache.ratis.server.raftlog.segmented.TestCacheEviction.testEvictionInSegmentedLog (#1640)

This is an automated email from the ASF dual-hosted git repository.

szetszwo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ratis.git


The following commit(s) were added to refs/heads/master by this push:
     new 0a9bdc96f RATIS-2746. Flaky org.apache.ratis.server.raftlog.segmented.TestCacheEviction.testEvictionInSegmentedLog (#1640)
0a9bdc96f is described below

commit 0a9bdc96fc2f3c577a7f1ec0caaf1ce54629f6fd
Author: Rui Wang <am...@apache.org>
AuthorDate: Thu Oct 15 02:00:53 2026 +0800

    RATIS-2746. Flaky org.apache.ratis.server.raftlog.segmented.TestCacheEviction.testEvictionInSegmentedLog (#1640)
---
 .../ratis/server/raftlog/segmented/TestCacheEviction.java      | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/ratis-test/src/test/java/org/apache/ratis/server/raftlog/segmented/TestCacheEviction.java b/ratis-test/src/test/java/org/apache/ratis/server/raftlog/segmented/TestCacheEviction.java
index 6ad429249..1fda66570 100644
--- a/ratis-test/src/test/java/org/apache/ratis/server/raftlog/segmented/TestCacheEviction.java
+++ b/ratis-test/src/test/java/org/apache/ratis/server/raftlog/segmented/TestCacheEviction.java
@@ -187,9 +187,13 @@ public class TestCacheEviction extends BaseTest {
     raftLog.append(entries).forEach(CompletableFuture::join);
 
     // check the cached segment number again. since the slowest follower is on
-    // index 21, the eviction should happen and evict 3 segments
-    Assertions.assertEquals(maxCachedNum + 1 - 3,
-        raftLog.getRaftLogCache().getCachedSegmentNum());
+    // index 21, the eviction should happen and evict 3 segments.
+    // The eviction runs asynchronously, so wait for it.
+    JavaUtils.attemptRepeatedly(() -> {
+      Assertions.assertEquals(maxCachedNum + 1 - 3,
+          raftLog.getRaftLogCache().getCachedSegmentNum());
+      return null;
+    }, 10, HUNDRED_MILLIS, "checkCachedSegmentNum", LOG);
   }
 
   private List<LogEntryProto> generateEntries(List<SegmentRange> slist) {