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 393fa122afe HBASE-28953 Prefetch thread shouldn't run for master store 
(#6438) (#6445)
393fa122afe is described below

commit 393fa122afe87244e13a548663a102381185e106
Author: Wellington Ramos Chevreuil <[email protected]>
AuthorDate: Fri Nov 15 11:40:39 2024 +0000

    HBASE-28953 Prefetch thread shouldn't run for master store (#6438) (#6445)
    
    Signed-off-by: Peter Somogyi <[email protected]>
    Signed-off-by: Ankit Singhal <[email protected]>
    Signed-off-by: Pankaj Kumar<[email protected]>
---
 .../hadoop/hbase/io/hfile/HFilePreadReader.java    |  3 ++-
 .../apache/hadoop/hbase/io/hfile/TestPrefetch.java | 22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFilePreadReader.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFilePreadReader.java
index 92f6a8169f3..92623731482 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFilePreadReader.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFilePreadReader.java
@@ -37,7 +37,8 @@ public class HFilePreadReader extends HFileReaderImpl {
   public HFilePreadReader(ReaderContext context, HFileInfo fileInfo, 
CacheConfig cacheConf,
     Configuration conf) throws IOException {
     super(context, fileInfo, cacheConf, conf);
-    final MutableBoolean shouldCache = new MutableBoolean(true);
+    // master hosted regions, like the master procedures store wouldn't have a 
block cache
+    final MutableBoolean shouldCache = new 
MutableBoolean(cacheConf.getBlockCache().isPresent());
 
     cacheConf.getBlockCache().ifPresent(cache -> {
       Optional<Boolean> result = cache.shouldCacheFile(path.getName());
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 bf27dc68b5c..cd2793b8cea 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
@@ -349,6 +349,28 @@ public class TestPrefetch {
     prefetchExecutorNotifier.onConfigurationChange(conf);
   }
 
+  @Test
+  public void testPrefetchWhenNoBlockCache() throws Exception {
+    PrefetchExecutorNotifier prefetchExecutorNotifier = new 
PrefetchExecutorNotifier(conf);
+    try {
+      // Set a delay to max, as we don't need to have the thread running, but 
rather
+      // assert that it never gets scheduled
+      conf.setInt(PREFETCH_DELAY, Integer.MAX_VALUE);
+      conf.setFloat(PREFETCH_DELAY_VARIATION, 0.0f);
+      prefetchExecutorNotifier.onConfigurationChange(conf);
+
+      HFileContext context = new 
HFileContextBuilder().withCompression(Compression.Algorithm.GZ)
+        .withBlockSize(DATA_BLOCK_SIZE).build();
+      Path storeFile = writeStoreFile("testPrefetchWhenNoBlockCache", context);
+      HFile.createReader(fs, storeFile, new CacheConfig(conf), true, conf);
+      assertEquals(0, PrefetchExecutor.getPrefetchFutures().size());
+    } finally {
+      conf.setInt(PREFETCH_DELAY, 1000);
+      conf.setFloat(PREFETCH_DELAY_VARIATION, 
PREFETCH_DELAY_VARIATION_DEFAULT_VALUE);
+      prefetchExecutorNotifier.onConfigurationChange(conf);
+    }
+  }
+
   @Test
   public void testPrefetchDoesntSkipHFileLink() throws Exception {
     testPrefetchWhenHFileLink(c -> {

Reply via email to