pvary commented on code in PR #3181:
URL: https://github.com/apache/hive/pull/3181#discussion_r843750551


##########
ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java:
##########
@@ -710,49 +691,32 @@ private Heartbeater startHeartbeat(long initialDelay) 
throws LockException {
     return task;
   }
 
-  private void stopHeartbeat() {
-    if (heartbeatTask == null) {
-      // avoid unnecessary locking if the field is null
-      return;
-    }
-
-    boolean isLockAcquired = false;
-    try {
-      // The lock should not be held by other thread trying to stop the 
heartbeat for more than 31 seconds
-      isLockAcquired = heartbeatTaskLock.tryLock(31000, TimeUnit.MILLISECONDS);
-    } catch (InterruptedException e) {
-      // safe to go on
-    }
-
-    try {
-      if (isLockAcquired && heartbeatTask != null) {
-        heartbeatTask.cancel(true);
-        long startTime = System.currentTimeMillis();
-        long sleepInterval = 100;
-        while (!heartbeatTask.isCancelled() && !heartbeatTask.isDone()) {
-          // We will wait for 30 seconds for the task to be cancelled.
-          // If it's still not cancelled (unlikely), we will just move on.
-          long now = System.currentTimeMillis();
-          if (now - startTime > 30000) {
-            LOG.warn("Heartbeat task cannot be cancelled for unknown reason. 
QueryId: " + queryId);
-            break;
-          }
-          try {
-            Thread.sleep(sleepInterval);
-          } catch (InterruptedException e) {
-          }
-          sleepInterval *= 2;
+  private synchronized void stopHeartbeat() {

Review Comment:
   Comment here as well



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to