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 0c365baad43 HBASE-28976 Fix UT flakeyness in
TestBucketCache.testBlockAdditionWaitWhenCache and
TestVerifyBucketCacheFile.testRetrieveFromFile (#6463) (#6475)
0c365baad43 is described below
commit 0c365baad439332d542b2cb1668af9308bde156a
Author: Wellington Ramos Chevreuil <[email protected]>
AuthorDate: Wed Nov 20 10:05:39 2024 +0000
HBASE-28976 Fix UT flakeyness in
TestBucketCache.testBlockAdditionWaitWhenCache and
TestVerifyBucketCacheFile.testRetrieveFromFile (#6463) (#6475)
Signed-off-by: Peter Somogyi <[email protected]>
---
.../hadoop/hbase/io/hfile/bucket/BucketCache.java | 3 +--
.../hadoop/hbase/io/hfile/bucket/TestBucketCache.java | 4 ++++
.../io/hfile/bucket/TestVerifyBucketCacheFile.java | 17 ++++++++++-------
3 files changed, 15 insertions(+), 9 deletions(-)
diff --git
a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
index fe8c565df78..3b08655bcfb 100644
---
a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
+++
b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
@@ -268,8 +268,7 @@ public class BucketCache implements BlockCache, HeapSize {
"hbase.bucketcache.persistent.file.integrity.check.algorithm";
private static final String DEFAULT_FILE_VERIFY_ALGORITHM = "MD5";
- private static final String QUEUE_ADDITION_WAIT_TIME =
- "hbase.bucketcache.queue.addition.waittime";
+ public static final String QUEUE_ADDITION_WAIT_TIME =
"hbase.bucketcache.queue.addition.waittime";
private static final long DEFAULT_QUEUE_ADDITION_WAIT_TIME = 0;
private long queueAdditionWaitTime;
/**
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketCache.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketCache.java
index fe1b2514b4d..c2e3b9d8a69 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketCache.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketCache.java
@@ -21,6 +21,7 @@ import static
org.apache.hadoop.hbase.io.hfile.bucket.BucketCache.ACCEPT_FACTOR_
import static
org.apache.hadoop.hbase.io.hfile.bucket.BucketCache.BLOCK_ORPHAN_GRACE_PERIOD;
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.apache.hadoop.hbase.io.hfile.bucket.BucketCache.QUEUE_ADDITION_WAIT_TIME;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
@@ -853,6 +854,9 @@ public class TestBucketCache {
String ioEngineName = "file:" + dataTestDir + "/bucketNoRecycler.cache";
String persistencePath = dataTestDir + "/bucketNoRecycler.persistence";
+ Configuration config = HBASE_TESTING_UTILITY.getConfiguration();
+ config.setLong(QUEUE_ADDITION_WAIT_TIME, 1000);
+
bucketCache = new BucketCache(ioEngineName, capacitySize,
constructedBlockSize,
constructedBlockSizes, 1, 1, persistencePath);
long usedByteSize = bucketCache.getAllocator().getUsedSize();
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestVerifyBucketCacheFile.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestVerifyBucketCacheFile.java
index 35cdb55c2c1..b677468c042 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestVerifyBucketCacheFile.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestVerifyBucketCacheFile.java
@@ -39,6 +39,7 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.Waiter;
import org.apache.hadoop.hbase.io.hfile.BlockCacheKey;
import org.apache.hadoop.hbase.io.hfile.CacheConfig;
import org.apache.hadoop.hbase.io.hfile.CacheTestUtils;
@@ -125,20 +126,22 @@ public class TestVerifyBucketCacheFile {
FileSystems.getDefault().getPath(testDir.toString(), "bucket.cache");
assertTrue(Files.deleteIfExists(cacheFile));
// can't restore cache from file
- bucketCache =
+ final BucketCache recoveredBucketCache =
new BucketCache("file:" + testDir + "/bucket.cache", capacitySize,
constructedBlockSize,
constructedBlockSizes, writeThreads, writerQLen, testDir +
"/bucket.persistence");
- Thread.sleep(100);
- assertEquals(0, bucketCache.getAllocator().getUsedSize());
- assertEquals(0, bucketCache.backingMap.size());
+ Waiter.waitFor(HBaseConfiguration.create(), 1000,
+ () -> recoveredBucketCache.getBackingMapValidated().get());
+ assertEquals(0, recoveredBucketCache.getAllocator().getUsedSize());
+ assertEquals(0, recoveredBucketCache.backingMap.size());
// Add blocks
for (CacheTestUtils.HFileBlockPair block : blocks) {
- cacheAndWaitUntilFlushedToBucket(bucketCache, block.getBlockName(),
block.getBlock());
+ cacheAndWaitUntilFlushedToBucket(recoveredBucketCache,
block.getBlockName(),
+ block.getBlock());
}
- usedSize = bucketCache.getAllocator().getUsedSize();
+ usedSize = recoveredBucketCache.getAllocator().getUsedSize();
assertNotEquals(0, usedSize);
// persist cache to file
- bucketCache.shutdown();
+ recoveredBucketCache.shutdown();
// 3.delete backingMap persistence file
final java.nio.file.Path mapFile =