This is an automated email from the ASF dual-hosted git repository.
wchevreuil pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/master by this push:
new b28d37d931e HBASE-30275
TestRecoveryPersistentBucketCache#testBucketCacheRecoveryWithAllocationInconsistencies
has a race condition between backingMapValidated and cacheState=ENABLED (#8456)
b28d37d931e is described below
commit b28d37d931e7bdb1664f53384a333b0737cdaa0d
Author: Aman Poonia <[email protected]>
AuthorDate: Wed Jul 8 15:28:55 2026 +0530
HBASE-30275
TestRecoveryPersistentBucketCache#testBucketCacheRecoveryWithAllocationInconsistencies
has a race condition between backingMapValidated and cacheState=ENABLED (#8456)
Signed-off-by: Wellington Chevreuil <[email protected]>
Signed-off-by: Viraj Jasani <[email protected]>
Signed-off-by: Peng Lu <[email protected]>
Reviewed-by: Umesh Kumar <[email protected]>
---
.../io/hfile/bucket/TestRecoveryPersistentBucketCache.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestRecoveryPersistentBucketCache.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestRecoveryPersistentBucketCache.java
index c3fcc267f47..adc072b8d50 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestRecoveryPersistentBucketCache.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestRecoveryPersistentBucketCache.java
@@ -22,10 +22,12 @@ import static
org.apache.hadoop.hbase.io.hfile.bucket.BucketCache.ACCEPT_FACTOR_
import static
org.apache.hadoop.hbase.io.hfile.bucket.BucketCache.DEFAULT_ERROR_TOLERATION_DURATION;
import static
org.apache.hadoop.hbase.io.hfile.bucket.BucketCache.EXTRA_FREE_FACTOR_CONFIG_NAME;
import static
org.apache.hadoop.hbase.io.hfile.bucket.BucketCache.MIN_FACTOR_CONFIG_NAME;
+import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.time.Duration;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseConfiguration;
@@ -251,9 +253,11 @@ public class TestRecoveryPersistentBucketCache {
BucketCache newBucketCache = new BucketCache("file:" + testDir +
"/bucket.cache", 36 * 1024,
8192, bucketSizes, writeThreads, writerQLen, testDir +
"/bucket.persistence",
DEFAULT_ERROR_TOLERATION_DURATION, conf);
- while (!newBucketCache.getBackingMapValidated().get()) {
- Thread.sleep(10);
- }
+ // backingMapValidated is set inside retrieveFromFile(), but
isCacheEnabled() (which
+ // getBlock() checks) is set to true only in the finally block that
follows. Waiting on
+ // backingMapValidated alone leaves a race window; await both conditions
together.
+
await().atMost(Duration.ofSeconds(30)).pollInterval(Duration.ofMillis(10)).until(
+ () -> newBucketCache.getBackingMapValidated().get() &&
newBucketCache.isCacheEnabled());
BlockCacheKey[] newKeys = CacheTestUtils.regenerateKeys(blocks, names);