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

guluo2016 pushed a commit to branch branch-3
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-3 by this push:
     new edd981e964f HBASE-30259 Async WAL archiving causes 
TestMasterRegionWALCleaner flaky (#8417)
edd981e964f is described below

commit edd981e964f206ac5434207b1ed73641d1959f0b
Author: Peng Lu <[email protected]>
AuthorDate: Fri Jun 26 23:27:04 2026 +0800

    HBASE-30259 Async WAL archiving causes TestMasterRegionWALCleaner flaky 
(#8417)
    
    Signed-off-by: Duo Zhang <[email protected]>
    Signed-off-by: Xiao Liu <[email protected]>
---
 .../master/region/TestMasterRegionWALCleaner.java      | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/region/TestMasterRegionWALCleaner.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/region/TestMasterRegionWALCleaner.java
index 7ff130833ee..546bcba2993 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/region/TestMasterRegionWALCleaner.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/region/TestMasterRegionWALCleaner.java
@@ -17,11 +17,13 @@
  */
 package org.apache.hadoop.hbase.master.region;
 
+import static org.awaitility.Awaitility.await;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
+import java.time.Duration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
@@ -82,14 +84,24 @@ public class TestMasterRegionWALCleaner extends 
MasterRegionTestBase {
     assertFalse(fs.exists(globalWALArchiveDir));
     region.requestRollAll();
     region.waitUntilWalRollFinished();
-    // should have one
+    // archiving wal is called in a background thread when rolling WALs, so it 
is possible that when
+    // waitUntilWalRollFinished returns, the archived WAL files have not been 
moved to the global
+    // archive directory yet, so here we need to wait for the directory to be 
created and the files
+    // to be moved.
+    await().atMost(Duration.ofSeconds(15)).untilAsserted(() -> {
+      assertTrue(fs.exists(globalWALArchiveDir));
+      assertEquals(1, fs.listStatus(globalWALArchiveDir).length);
+    });
     FileStatus[] files = fs.listStatus(globalWALArchiveDir);
     assertEquals(1, files.length);
+    // Rebase the WAL mtime so the following timing assertions are not 
affected by the wait above.
+    // Cleaner TTL is based on file mtime.
+    fs.setTimes(files[0].getPath(), System.currentTimeMillis(), -1);
     Thread.sleep(2000);
     // should still be there
     assertTrue(fs.exists(files[0].getPath()));
-    Thread.sleep(6000);
     // should have been cleaned
-    assertEquals(0, fs.listStatus(globalWALArchiveDir).length);
+    await().atMost(Duration.ofSeconds(15))
+      .untilAsserted(() -> assertEquals(0, 
fs.listStatus(globalWALArchiveDir).length));
   }
 }

Reply via email to