[
https://issues.apache.org/jira/browse/HBASE-29566?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18018994#comment-18018994
]
Diya Maria Abraham commented on HBASE-29566:
--------------------------------------------
The race condition occurs between the {{while}} condition evaluation and the
{{assertTrue}} execution:
# Thread 1 (test): Checks {{!reader.prefetchStarted()}} → returns {{true}}
(prefetch not started)
# Thread 2 (prefetch): Starts prefetch → {{reader.prefetchStarted()}} becomes
{{true}}
# Thread 1 (test): Executes {{assertTrue}} with {{getElapsedTime(startTime) <
PrefetchExecutor.getPrefetchDelay()}} → *FAILS* because enough time has passed
This timing issue explains why the test fails intermittently with "Prefetch
delay has not been expired yet" even though the prefetch actually started at
the correct time.
> TestPrefetch.testPrefetchWithDelay seems flakey
> -----------------------------------------------
>
> Key: HBASE-29566
> URL: https://issues.apache.org/jira/browse/HBASE-29566
> Project: HBase
> Issue Type: Bug
> Reporter: Wellington Chevreuil
> Assignee: Diya Maria Abraham
> Priority: Major
>
> Noticed this TestPrefetch.testPrefetchWithDelay failing intermittently at
> branch-2.6 at least.
> {noformat}
> java.lang.AssertionError: Prefetch delay has not been expired yet
> at org.junit.Assert.fail(Assert.java:89)
> at org.junit.Assert.assertTrue(Assert.java:42)
> at
> org.apache.hadoop.hbase.io.hfile.TestPrefetch.testPrefetchWithDelay(TestPrefetch.java:330)
> at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.base/java.lang.reflect.Method.invoke(Method.java:566)
> at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
> {noformat}
> I believe the problem is in the while condition block:
> {noformat}
> ...
> while (!reader.prefetchStarted()) {
> assertTrue("Prefetch delay has not been expired yet",
> getElapsedTime(startTime) < PrefetchExecutor.getPrefetchDelay());
> }
> ...
> {noformat}
> We are assuming prefetch will start right away the delay, but this may not be
> guaranteed.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)