HBASE-1422 Delayed flush doesn't work causing flush storms; addendum by Lars Hofhansl
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/b1462679 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/b1462679 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/b1462679 Branch: refs/heads/hbase-12439 Commit: b1462679e17f9b5827720f3c57eaeff946cfea0e Parents: 80afb83 Author: stack <st...@apache.org> Authored: Sat Dec 5 11:39:34 2015 -0800 Committer: stack <st...@apache.org> Committed: Sat Dec 5 11:39:34 2015 -0800 ---------------------------------------------------------------------- .../hadoop/hbase/JitterScheduledThreadPoolExecutorImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/b1462679/hbase-common/src/main/java/org/apache/hadoop/hbase/JitterScheduledThreadPoolExecutorImpl.java ---------------------------------------------------------------------- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/JitterScheduledThreadPoolExecutorImpl.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/JitterScheduledThreadPoolExecutorImpl.java index ca15286..7e7239e 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/JitterScheduledThreadPoolExecutorImpl.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/JitterScheduledThreadPoolExecutorImpl.java @@ -81,7 +81,8 @@ public class JitterScheduledThreadPoolExecutorImpl extends ScheduledThreadPoolEx public long getDelay(TimeUnit unit) { long baseDelay = wrapped.getDelay(unit); long spreadTime = (long) (baseDelay * spread); - long delay = baseDelay + ThreadLocalRandom.current().nextLong(-spreadTime, spreadTime); + long delay = spreadTime <= 0 ? baseDelay + : baseDelay + ThreadLocalRandom.current().nextLong(-spreadTime, spreadTime); // Ensure that we don't roll over for nanoseconds. return (delay < 0) ? baseDelay : delay; }