Skip to content

Commit f38863e

Browse files
committed
HBASE-30255 Async archiving wal file causes TestLogRolling flaky
1 parent 1517a07 commit f38863e

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestLogRolling.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818
package org.apache.hadoop.hbase.regionserver.wal;
1919

20+
import static org.awaitility.Awaitility.await;
2021
import static org.hamcrest.MatcherAssert.assertThat;
2122
import static org.hamcrest.Matchers.greaterThan;
2223
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -25,6 +26,7 @@
2526
import static org.junit.jupiter.api.Assertions.assertTrue;
2627

2728
import java.io.IOException;
29+
import java.time.Duration;
2830
import java.util.concurrent.Executors;
2931
import java.util.concurrent.ScheduledExecutorService;
3032
import java.util.concurrent.atomic.AtomicBoolean;
@@ -304,8 +306,13 @@ public void testLogRolling() throws Exception {
304306
log.rollWriter();
305307

306308
// should have deleted all the rolled wal files
307-
TEST_UTIL.waitFor(5000, () -> AbstractFSWALProvider.getNumRolledLogFiles(log) == 0);
308-
assertEquals(0, AbstractFSWALProvider.getLogFileSize(log));
309+
await().atMost(Duration.ofSeconds(15)).untilAsserted(() -> {
310+
// we call archive log in a background thread but remove the log from wal file map in
311+
// foreground, which means it is possible that when numRolledLogFiles reaches zero, the log
312+
// file size is still greater than zero, so here we need to wait for them both.
313+
assertEquals(0, AbstractFSWALProvider.getNumRolledLogFiles(log));
314+
assertEquals(0, AbstractFSWALProvider.getLogFileSize(log));
315+
});
309316
}
310317

311318
protected String getName() {

0 commit comments

Comments
 (0)