You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by pr...@apache.org on 2019/07/07 05:02:25 UTC

[hive] branch master updated: HIVE-21925: HiveConnection retries should support backoff (Rajkumar Singh reviewed by Prasanth Jayachandran)

This is an automated email from the ASF dual-hosted git repository.

prasanthj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new 71adb04  HIVE-21925: HiveConnection retries should support backoff (Rajkumar Singh reviewed by Prasanth Jayachandran)
71adb04 is described below

commit 71adb04eaec81a0501621af4b06c1f9b0e3fc024
Author: Rajkumar Singh <ra...@cloudera.com>
AuthorDate: Sat Jul 6 22:01:15 2019 -0700

    HIVE-21925: HiveConnection retries should support backoff (Rajkumar Singh reviewed by Prasanth Jayachandran)
---
 jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java | 12 +++++++++++-
 jdbc/src/java/org/apache/hive/jdbc/Utils.java          |  1 +
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
index ec9c193..cb0b0d1 100644
--- a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
+++ b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
@@ -298,11 +298,16 @@ public class HiveConnection implements java.sql.Connection {
       executeInitSql();
     } else {
       int maxRetries = 1;
+      long retryInterval = 1000L;
       try {
         String strRetries = sessConfMap.get(JdbcConnectionParams.RETRIES);
         if (StringUtils.isNotBlank(strRetries)) {
           maxRetries = Integer.parseInt(strRetries);
         }
+        String strRetryInterval = sessConfMap.get(JdbcConnectionParams.RETRY_INTERVAL);
+        if(StringUtils.isNotBlank(strRetryInterval)){
+          retryInterval = Long.parseLong(strRetryInterval);
+        }
       } catch(NumberFormatException e) { // Ignore the exception
       }
 
@@ -343,7 +348,12 @@ public class HiveConnection implements java.sql.Connection {
           if (numRetries >= maxRetries) {
             throw new SQLException(errMsg + e.getMessage(), " 08S01", e);
           } else {
-            LOG.warn(warnMsg + e.getMessage() + " Retrying " + numRetries + " of " + maxRetries);
+            LOG.warn(warnMsg + e.getMessage() + " Retrying " + numRetries + " of " + maxRetries+" with retry interval "+retryInterval+"ms");
+            try {
+              Thread.sleep(retryInterval);
+            } catch (InterruptedException ex) {
+              //Ignore
+            }
           }
         }
       }
diff --git a/jdbc/src/java/org/apache/hive/jdbc/Utils.java b/jdbc/src/java/org/apache/hive/jdbc/Utils.java
index 3c18f09..e23826e 100644
--- a/jdbc/src/java/org/apache/hive/jdbc/Utils.java
+++ b/jdbc/src/java/org/apache/hive/jdbc/Utils.java
@@ -81,6 +81,7 @@ public class Utils {
 
     // Retry setting
     static final String RETRIES = "retries";
+    public static final String RETRY_INTERVAL = "retryInterval";
 
     public static final String AUTH_TYPE = "auth";
     // We're deprecating this variable's name.