This is an automated email from the ASF dual-hosted git repository. zhangduo pushed a commit to branch branch-2.5 in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.5 by this push: new 1ae88f9c0fe HBASE-27888 Record readBlock message in log when it takes too long time (#5255) 1ae88f9c0fe is described below commit 1ae88f9c0fe06f5e125fa25a05929d4b93e240d6 Author: chaijunjie0101 <64140218+chaijunjie0...@users.noreply.github.com> AuthorDate: Fri Jun 16 23:15:24 2023 +0800 HBASE-27888 Record readBlock message in log when it takes too long time (#5255) Signed-off-by: Duo Zhang <zhang...@apache.org> (cherry picked from commit 663bc642b6d6b4e364bdeddcf197a0fa2fd8e228) --- .../java/org/apache/hadoop/hbase/io/hfile/HFileBlock.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlock.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlock.java index 909f78e6e3d..1c7bc73e604 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlock.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlock.java @@ -1356,6 +1356,13 @@ public class HFileBlock implements Cacheable { private final boolean isPreadAllBytes; + private final long readWarnTime; + + /** + * If reading block cost time in milliseconds more than the threshold, a warning will be logged. + */ + public static final String FS_READER_WARN_TIME_MS = "hbase.fs.reader.warn.time.ms"; + FSReaderImpl(ReaderContext readerContext, HFileContext fileContext, ByteBuffAllocator allocator, Configuration conf) throws IOException { this.fileSize = readerContext.getFileSize(); @@ -1373,6 +1380,8 @@ public class HFileBlock implements Cacheable { defaultDecodingCtx = new HFileBlockDefaultDecodingContext(conf, fileContext); encodedBlockDecodingCtx = defaultDecodingCtx; isPreadAllBytes = readerContext.isPreadAllBytes(); + // Default warn threshold set to -1, it means skipping record the read block slow warning log. + readWarnTime = conf.getLong(FS_READER_WARN_TIME_MS, -1L); } @Override @@ -1730,6 +1739,10 @@ public class HFileBlock implements Cacheable { hFileBlock.sanityCheckUncompressed(); } LOG.trace("Read {} in {} ms", hFileBlock, duration); + if (!LOG.isTraceEnabled() && this.readWarnTime >= 0 && duration > this.readWarnTime) { + LOG.warn("Read Block Slow: read {} cost {} ms, threshold = {} ms", hFileBlock, duration, + this.readWarnTime); + } span.addEvent("Read block", attributesBuilder.build()); // Cache next block header if we read it for the next time through here. if (nextBlockOnDiskSize != -1) {