diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java index 82f5366..b9184a6 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java @@ -1418,12 +1418,13 @@ public class HFileReaderImpl implements HFile.Reader, Configurable { TraceScope traceScope = Trace.startSpan("HFileReaderImpl.readBlock"); try { while (true) { - if (useLock) { - lockEntry = offsetLock.getLockEntry(dataBlockOffset); - } // Check cache for block. If found return. if (cacheConf.isBlockCacheEnabled()) { + // Only lock when blockCacheEnabled + if (useLock) { + lockEntry = offsetLock.getLockEntry(dataBlockOffset); + } // Try and get the block from the block cache. If the useLock variable is true then this // is the second time through the loop and it should not be counted as a block cache miss. HFileBlock cachedBlock = getCachedBlock(cacheKey, cacheBlock, useLock, isCompaction, @@ -1449,12 +1450,13 @@ public class HFileReaderImpl implements HFile.Reader, Configurable { return cachedBlock; } // Carry on, please load. + if (!useLock) { + // check cache again with lock + useLock = true; + continue; + } } - if (!useLock) { - // check cache again with lock - useLock = true; - continue; - } + if (Trace.isTracing()) { traceScope.getSpan().addTimelineAnnotation("blockCacheMiss"); }