Skip to content

Commit 393fa12

Browse files
committed
HBASE-28953 Prefetch thread shouldn't run for master store (#6438) (#6445)
Signed-off-by: Peter Somogyi <psomogyi@apache.org> Signed-off-by: Ankit Singhal <ankit@apache.org> Signed-off-by: Pankaj Kumar<pankajkumar@apache.org>
1 parent 42b401a commit 393fa12

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFilePreadReader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ public class HFilePreadReader extends HFileReaderImpl {
3737
public HFilePreadReader(ReaderContext context, HFileInfo fileInfo, CacheConfig cacheConf,
3838
Configuration conf) throws IOException {
3939
super(context, fileInfo, cacheConf, conf);
40-
final MutableBoolean shouldCache = new MutableBoolean(true);
40+
// master hosted regions, like the master procedures store wouldn't have a block cache
41+
final MutableBoolean shouldCache = new MutableBoolean(cacheConf.getBlockCache().isPresent());
4142

4243
cacheConf.getBlockCache().ifPresent(cache -> {
4344
Optional<Boolean> result = cache.shouldCacheFile(path.getName());

hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestPrefetch.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,28 @@ public void testPrefetchWithDelay() throws Exception {
349349
prefetchExecutorNotifier.onConfigurationChange(conf);
350350
}
351351

352+
@Test
353+
public void testPrefetchWhenNoBlockCache() throws Exception {
354+
PrefetchExecutorNotifier prefetchExecutorNotifier = new PrefetchExecutorNotifier(conf);
355+
try {
356+
// Set a delay to max, as we don't need to have the thread running, but rather
357+
// assert that it never gets scheduled
358+
conf.setInt(PREFETCH_DELAY, Integer.MAX_VALUE);
359+
conf.setFloat(PREFETCH_DELAY_VARIATION, 0.0f);
360+
prefetchExecutorNotifier.onConfigurationChange(conf);
361+
362+
HFileContext context = new HFileContextBuilder().withCompression(Compression.Algorithm.GZ)
363+
.withBlockSize(DATA_BLOCK_SIZE).build();
364+
Path storeFile = writeStoreFile("testPrefetchWhenNoBlockCache", context);
365+
HFile.createReader(fs, storeFile, new CacheConfig(conf), true, conf);
366+
assertEquals(0, PrefetchExecutor.getPrefetchFutures().size());
367+
} finally {
368+
conf.setInt(PREFETCH_DELAY, 1000);
369+
conf.setFloat(PREFETCH_DELAY_VARIATION, PREFETCH_DELAY_VARIATION_DEFAULT_VALUE);
370+
prefetchExecutorNotifier.onConfigurationChange(conf);
371+
}
372+
}
373+
352374
@Test
353375
public void testPrefetchDoesntSkipHFileLink() throws Exception {
354376
testPrefetchWhenHFileLink(c -> {

0 commit comments

Comments
 (0)