From c120260bceb5df2765f12dc7624e5fd214b2dac5 Mon Sep 17 00:00:00 2001 From: jacob-leblanc <56317445+jacob-leblanc@users.noreply.github.com> Date: Sun, 31 May 2020 00:06:40 -0400 Subject: [PATCH] HBASE-24454 - Read ioErrorStartTime to local temporary variable to avoid issue when it is set to -1 between greater than zero check and calculation of error duration (#1816) Signed-off-by Anoop Sam John --- .../apache/hadoop/hbase/io/hfile/bucket/BucketCache.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java index d74f63d10b1..a205d27f872 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java @@ -1175,8 +1175,10 @@ public class BucketCache implements BlockCache, HeapSize { */ private void checkIOErrorIsTolerated() { long now = EnvironmentEdgeManager.currentTime(); - if (this.ioErrorStartTime > 0) { - if (cacheEnabled && (now - ioErrorStartTime) > this.ioErrorsTolerationDuration) { + // Do a single read to a local variable to avoid timing issue - HBASE-24454 + long ioErrorStartTimeTmp = this.ioErrorStartTime; + if (ioErrorStartTimeTmp > 0) { + if (cacheEnabled && (now - ioErrorStartTimeTmp) > this.ioErrorsTolerationDuration) { LOG.error("IO errors duration time has exceeded " + ioErrorsTolerationDuration + "ms, disabling cache, please check your IOEngine"); disableCache();