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

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


The following commit(s) were added to refs/heads/branch-2.6 by this push:
     new 313b9cc799a HBASE-29566: TestPrefetch.testPrefetchWithDelay seems 
flakey (#7287)
313b9cc799a is described below

commit 313b9cc799a0c37b735664f79761bc930728c803
Author: Diya Maria Abraham <[email protected]>
AuthorDate: Thu Sep 11 20:21:53 2025 +0530

    HBASE-29566: TestPrefetch.testPrefetchWithDelay seems flakey (#7287)
    
    Signed-off-by: Wellington Chevreuil <[email protected]>
---
 .../apache/hadoop/hbase/io/hfile/TestPrefetch.java    | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestPrefetch.java 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestPrefetch.java
index 8e278e40336..c9966745d71 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestPrefetch.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestPrefetch.java
@@ -54,6 +54,7 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.MatcherPredicate;
 import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.Waiter;
 import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
 import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
 import org.apache.hadoop.hbase.client.RegionInfo;
@@ -326,16 +327,14 @@ public class TestPrefetch {
     // Wait for 20 seconds, no thread should start prefetch
     Thread.sleep(20000);
     assertFalse("Prefetch threads should not be running at this point", 
reader.prefetchStarted());
-    while (!reader.prefetchStarted()) {
-      assertTrue("Prefetch delay has not been expired yet",
-        getElapsedTime(startTime) < PrefetchExecutor.getPrefetchDelay());
-    }
-    if (reader.prefetchStarted()) {
-      // Added some delay as we have started the timer a bit late.
-      Thread.sleep(500);
-      assertTrue("Prefetch should start post configured delay",
-        getElapsedTime(startTime) > PrefetchExecutor.getPrefetchDelay());
-    }
+    long timeout = 10000;
+    Waiter.waitFor(conf, 10000, () -> (reader.prefetchStarted() || 
reader.prefetchComplete()));
+
+    assertTrue(reader.prefetchStarted() || reader.prefetchComplete());
+
+    assertTrue("Prefetch should start post configured delay",
+      getElapsedTime(startTime) > PrefetchExecutor.getPrefetchDelay());
+
     conf.setInt(PREFETCH_DELAY, 1000);
     conf.setFloat(PREFETCH_DELAY_VARIATION, 
PREFETCH_DELAY_VARIATION_DEFAULT_VALUE);
     prefetchExecutorNotifier.onConfigurationChange(conf);

Reply via email to