You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by wc...@apache.org on 2024/11/06 12:55:24 UTC
(hbase) branch master updated: HBASE-28953 Prefetch thread shouldn't run for master store (#6438)
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 3c267df5677 HBASE-28953 Prefetch thread shouldn't run for master store (#6438)
3c267df5677 is described below
commit 3c267df56772375ea0da8adc7c12f8c9f7791a3a
Author: Wellington Ramos Chevreuil <wc...@apache.org>
AuthorDate: Wed Nov 6 12:55:19 2024 +0000
HBASE-28953 Prefetch thread shouldn't run for master store (#6438)
Signed-off-by: Peter Somogyi <ps...@apache.org>
Signed-off-by: Ankit Singhal <an...@apache.org>
---
.../hadoop/hbase/io/hfile/HFilePreadReader.java | 8 ++++----
.../apache/hadoop/hbase/io/hfile/TestPrefetch.java | 22 ++++++++++++++++++++++
2 files changed, 26 insertions(+), 4 deletions(-)
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 bfa807d4a6f..6266be6cbcc 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
@@ -39,16 +39,16 @@ public class HFilePreadReader extends HFileReaderImpl {
public HFilePreadReader(ReaderContext context, HFileInfo fileInfo, CacheConfig cacheConf,
Configuration conf) throws IOException {
super(context, fileInfo, cacheConf, conf);
-
+ // master hosted regions, like the master procedures store wouldn't have a block cache
+ final MutableBoolean shouldCache = new MutableBoolean(cacheConf.getBlockCache().isPresent());
// Prefetch file blocks upon open if requested
- if (cacheConf.shouldPrefetchOnOpen()) {
+ if (shouldCache.booleanValue() && cacheConf.shouldPrefetchOnOpen()) {
PrefetchExecutor.request(path, new Runnable() {
@Override
public void run() {
long offset = 0;
long end = 0;
HFile.Reader prefetchStreamReader = null;
- final MutableBoolean shouldCache = new MutableBoolean(true);
try {
cacheConf.getBlockCache().ifPresent(cache -> {
cache.waitForCacheInitialization(WAIT_TIME_FOR_CACHE_INITIALIZATION);
@@ -56,7 +56,7 @@ public class HFilePreadReader extends HFileReaderImpl {
shouldCache.setValue(result.isPresent() ? result.get().booleanValue() : true);
});
if (!shouldCache.booleanValue()) {
- LOG.info("Prefetch skipped for the file: " + path.getName());
+ LOG.info("Prefetch skipped for file: {}", path);
return;
}
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 4a6cf008155..096abd80978 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
@@ -381,6 +381,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 -> {