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

ayushsaxena 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 153b78e8d08 HIVE-24404: Invoke getUserName before getMSC to avoid 
metastore client connection been closed and retry (#3883). (Laszlo Bodor 
reviewed by Ayush Saxena)
153b78e8d08 is described below

commit 153b78e8d082ee6cfe68db976beffb759010e025
Author: Bodor Laszlo <bodorlaszlo0...@gmail.com>
AuthorDate: Mon Jan 23 08:02:33 2023 +0100

    HIVE-24404: Invoke getUserName before getMSC to avoid metastore client 
connection been closed and retry (#3883). (Laszlo Bodor reviewed by Ayush 
Saxena)
---
 ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java 
b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
index 4acbb580b3a..dbdece0d4f4 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
@@ -3598,8 +3598,9 @@ private void constructOneLBLocationMap(FileStatus fSta,
     }
     org.apache.hadoop.hive.metastore.api.Partition tpart = null;
     try {
+      String userName = getUserName();
       tpart = getSynchronizedMSC().getPartitionWithAuthInfo(tbl.getDbName(),
-          tbl.getTableName(), pvals, getUserName(), getGroupNames());
+          tbl.getTableName(), pvals, userName, getGroupNames());
     } catch (NoSuchObjectException nsoe) {
       // this means no partition exists for the given partition
       // key value pairs - thrift cannot handle null return values, hence
@@ -3618,8 +3619,9 @@ private void constructOneLBLocationMap(FileStatus fSta,
             tpart = getSynchronizedMSC().appendPartition(tbl.getDbName(), 
tbl.getTableName(), pvals);
           } catch (AlreadyExistsException aee) {
             LOG.debug("Caught already exists exception, trying to alter 
partition instead");
+            String userName = getUserName();
             tpart = 
getSynchronizedMSC().getPartitionWithAuthInfo(tbl.getDbName(),
-              tbl.getTableName(), pvals, getUserName(), getGroupNames());
+              tbl.getTableName(), pvals, userName, getGroupNames());
             alterPartitionSpec(tbl, partSpec, tpart, inheritTableSpecs, 
partPath);
           } catch (Exception e) {
             if (CheckJDOException.isJDODataStoreException(e)) {
@@ -3627,8 +3629,9 @@ private void constructOneLBLocationMap(FileStatus fSta,
               // have to be used here. This helps avoid adding jdo dependency 
for
               // hcatalog client uses
               LOG.debug("Caught JDO exception, trying to alter partition 
instead");
+              String userName = getUserName();
               tpart = 
getSynchronizedMSC().getPartitionWithAuthInfo(tbl.getDbName(),
-                tbl.getTableName(), pvals, getUserName(), getGroupNames());
+                tbl.getTableName(), pvals, userName, getGroupNames());
               if (tpart == null) {
                 // This means the exception was caused by something other than 
a race condition
                 // in creating the partition, since the partition still 
doesn't exist.
@@ -4060,8 +4063,9 @@ private void constructOneLBLocationMap(FileStatus fSta,
 
       List<org.apache.hadoop.hive.metastore.api.Partition> partitions = null;
       try {
+        String userName = getUserName();
         partitions = getMSC().listPartitionsWithAuthInfo(tbl.getDbName(), 
tbl.getTableName(),
-                partialPvals, limit, getUserName(), getGroupNames());
+                partialPvals, limit, userName, getGroupNames());
       } catch (Exception e) {
         throw new HiveException(e);
       }

Reply via email to