Repository: hive Updated Branches: refs/heads/master 733bc5f02 -> 75671197c
HIVE-17341 - DbTxnManger.startHeartbeat() - randomize initial delay (Eugene Koifman, reviewed by Wei Zheng) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/1938eeb5 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/1938eeb5 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/1938eeb5 Branch: refs/heads/master Commit: 1938eeb5948bd1e2443d785cf4b1896cc2c3d4c5 Parents: 733bc5f Author: Eugene Koifman <ekoif...@hortonworks.com> Authored: Fri Aug 25 12:47:01 2017 -0700 Committer: Eugene Koifman <ekoif...@hortonworks.com> Committed: Fri Aug 25 12:47:01 2017 -0700 ---------------------------------------------------------------------- .../java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/1938eeb5/ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java b/ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java index 03d5b09..5dec791 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java @@ -639,8 +639,12 @@ public final class DbTxnManager extends HiveTxnManagerImpl { if(conf.getBoolVar(HiveConf.ConfVars.HIVE_IN_TEST) && conf.getBoolVar(HiveConf.ConfVars.HIVETESTMODEFAILHEARTBEATER)) { initialDelay = 0; } else if (initialDelay == 0) { - initialDelay = heartbeatInterval; + /*make initialDelay a random number in [0, 0.75*heartbeatInterval] so that if a lot + of queries land on the server at the same time and all get blocked on lack of + resources, that they all don't start heartbeating at the same time*/ + initialDelay = (long)Math.floor(heartbeatInterval * 0.75 * Math.random()); } + heartbeatTask = heartbeatExecutorService.scheduleAtFixedRate( heartbeater, initialDelay, heartbeatInterval, TimeUnit.MILLISECONDS); LOG.info("Started heartbeat with delay/interval = " + initialDelay + "/" + heartbeatInterval +