Repository: hive
Updated Branches:
  refs/heads/master fad53983b -> dfb868d1a


HIVE-15090: Temporary DB failure can stop ExpiredTokenRemover thread (Peter 
Vary, reviewed by Aihua Xu)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/dfb868d1
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/dfb868d1
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/dfb868d1

Branch: refs/heads/master
Commit: dfb868d1af5bcc0db517c4a7d3675d1971284ef3
Parents: fad5398
Author: Aihua Xu <aihu...@apache.org>
Authored: Mon Nov 7 09:09:00 2016 -0500
Committer: Aihua Xu <aihu...@apache.org>
Committed: Mon Nov 7 09:09:00 2016 -0500

----------------------------------------------------------------------
 .../TokenStoreDelegationTokenSecretManager.java | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/dfb868d1/shims/common/src/main/java/org/apache/hadoop/hive/thrift/TokenStoreDelegationTokenSecretManager.java
----------------------------------------------------------------------
diff --git 
a/shims/common/src/main/java/org/apache/hadoop/hive/thrift/TokenStoreDelegationTokenSecretManager.java
 
b/shims/common/src/main/java/org/apache/hadoop/hive/thrift/TokenStoreDelegationTokenSecretManager.java
index abe8cc2..4d910d8 100644
--- 
a/shims/common/src/main/java/org/apache/hadoop/hive/thrift/TokenStoreDelegationTokenSecretManager.java
+++ 
b/shims/common/src/main/java/org/apache/hadoop/hive/thrift/TokenStoreDelegationTokenSecretManager.java
@@ -293,8 +293,8 @@ public class TokenStoreDelegationTokenSecretManager extends 
DelegationTokenSecre
       LOGGER.info("Starting expired delegation token remover thread, "
           + "tokenRemoverScanInterval=" + tokenRemoverScanInterval
           / (60 * 1000) + " min(s)");
-      try {
-        while (running) {
+      while (running) {
+        try {
           long now = System.currentTimeMillis();
           if (lastMasterKeyUpdate + keyUpdateInterval < now) {
             try {
@@ -313,13 +313,21 @@ public class TokenStoreDelegationTokenSecretManager 
extends DelegationTokenSecre
             Thread.sleep(5000); // 5 seconds
           } catch (InterruptedException ie) {
             LOGGER
-            .error("InterruptedExcpetion recieved for ExpiredTokenRemover 
thread "
+            .error("InterruptedException received for ExpiredTokenRemover 
thread "
                 + ie);
           }
+        } catch (Throwable t) {
+          LOGGER.error("ExpiredTokenRemover thread received unexpected 
exception. "
+                           + t, t);
+          // Wait 5 seconds too in case of an exception, so we do not end up 
in busy waiting for
+          // the solution for this exception
+          try {
+            Thread.sleep(5000); // 5 seconds
+          } catch (InterruptedException ie) {
+            LOGGER.error("InterruptedException received for 
ExpiredTokenRemover thread during " +
+                "wait in exception sleep " + ie);
+          }
         }
-      } catch (Throwable t) {
-        LOGGER.error("ExpiredTokenRemover thread received unexpected 
exception. "
-            + t, t);
       }
     }
   }

Reply via email to