deniskuzZ commented on code in PR #5398:
URL: https://github.com/apache/hive/pull/5398#discussion_r1728763063


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -602,18 +594,18 @@ public long getNextCSIdForMPartitionColumnStatistics(long 
numStats) throws MetaE
       try (Statement statement = dbConn.createStatement()) {
         statement.executeUpdate(query);
       }
-      dbConn.commit();
-      committed = true;
+      closeDbConn(jdoConn);
+      tx.commit();
       return maxCsId;
     } catch (Exception e) {
       LOG.error("Unable to getNextCSIdForMPartitionColumnStatistics", e);
       throw new MetaException("Unable to 
getNextCSIdForMPartitionColumnStatistics  "
               + " due to: " + e.getMessage());
     } finally {
-      if (!committed) {
-        rollbackDBConn(dbConn);
+      if (tx.isActive()) {
+        closeDbConn(jdoConn);

Review Comment:
   how about a nested try, since it doesn't implement auto-closeble
   ````
   try {
       dbType.lockInternal();
       tx.begin();
       try {
           jdoConn = pm.getDataStoreConnection();
       ....
       } finally {
           closeDbConn(jdoConn);
       }
       tx.commit();
   }
   ````
   finally {
       if (tx.isActive()) { 
           tx.rollback(); 
       }
   }



##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdatePart.java:
##########
@@ -602,18 +594,18 @@ public long getNextCSIdForMPartitionColumnStatistics(long 
numStats) throws MetaE
       try (Statement statement = dbConn.createStatement()) {
         statement.executeUpdate(query);
       }
-      dbConn.commit();
-      committed = true;
+      closeDbConn(jdoConn);
+      tx.commit();
       return maxCsId;
     } catch (Exception e) {
       LOG.error("Unable to getNextCSIdForMPartitionColumnStatistics", e);
       throw new MetaException("Unable to 
getNextCSIdForMPartitionColumnStatistics  "
               + " due to: " + e.getMessage());
     } finally {
-      if (!committed) {
-        rollbackDBConn(dbConn);
+      if (tx.isActive()) {
+        closeDbConn(jdoConn);

Review Comment:
   how about a nested try, since it doesn't implement auto-closeble
   ````
   try {
       dbType.lockInternal();
       tx.begin();
       try {
           jdoConn = pm.getDataStoreConnection();
       ....
       } finally {
           closeDbConn(jdoConn);
       }
       tx.commit();
   }
   ..
   finally {
       if (tx.isActive()) { 
           tx.rollback(); 
       }
   }
   ````



-- 
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: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to