dengzhhu653 commented on a change in pull request #1078:
URL: https://github.com/apache/hive/pull/1078#discussion_r437147690



##########
File path: 
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/VerifyingObjectStore.java
##########
@@ -93,9 +93,11 @@ public boolean getPartitionsByExpr(String catName, String 
dbName, String tblName
   @Override
   public List<Partition> getPartitions(
       String catName, String dbName, String tableName, int maxParts) throws 
MetaException, NoSuchObjectException {
+    openTransaction();
     List<Partition> sqlResults = getPartitionsInternal(catName, dbName, 
tableName, maxParts, true, false);
     List<Partition> ormResults = getPartitionsInternal(catName, dbName, 
tableName, maxParts, false, true);
     verifyLists(sqlResults, ormResults, Partition.class);
+    commitTransaction();

Review comment:
       what if exception happens when getPartitionsInternal,  the transaction 
may become unbalanced

##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
##########
@@ -7109,22 +7121,37 @@ protected String describeResult() {
   }
 
   @Override
-  public List<HiveObjectPrivilege> listPrincipalDBGrantsAll(
-      String principalName, PrincipalType principalType) {
-    try (QueryWrapper queryWrapper = new QueryWrapper()) {
-      return convertDB(listPrincipalAllDBGrant(principalName, principalType, 
queryWrapper));
+  public List<HiveObjectPrivilege> listPrincipalDBGrantsAll(String 
principalName, PrincipalType principalType) {
+    List<HiveObjectPrivilege> results = Collections.emptyList();
+    try {
+      openTransaction();
+      results = convertDB(listPrincipalAllDBGrant(principalName, 
principalType));
+      commitTransaction();
+    } catch (Exception e) {
+      throw new RuntimeException(e);
+    } finally {
+      rollbackAndCleanup(true, null);
     }
+    return results;
   }
 
   @Override
   public List<HiveObjectPrivilege> listDBGrantsAll(String catName, String 
dbName) {
-    return listDBGrantsAll(catName, dbName, null);
+    List<HiveObjectPrivilege> results = Collections.emptyList();
+    try {
+      openTransaction();
+      results = listDBGrantsAll(catName, dbName, null);
+      commitTransaction();
+    } catch (Exception e) {
+      throw new RuntimeException(e);
+    } finally {
+      rollbackAndCleanup(true, null);

Review comment:
       Why pass true to rollbackAndCleanup here?

##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
##########
@@ -7109,22 +7121,37 @@ protected String describeResult() {
   }
 
   @Override
-  public List<HiveObjectPrivilege> listPrincipalDBGrantsAll(
-      String principalName, PrincipalType principalType) {
-    try (QueryWrapper queryWrapper = new QueryWrapper()) {
-      return convertDB(listPrincipalAllDBGrant(principalName, principalType, 
queryWrapper));
+  public List<HiveObjectPrivilege> listPrincipalDBGrantsAll(String 
principalName, PrincipalType principalType) {
+    List<HiveObjectPrivilege> results = Collections.emptyList();
+    try {
+      openTransaction();
+      results = convertDB(listPrincipalAllDBGrant(principalName, 
principalType));
+      commitTransaction();
+    } catch (Exception e) {
+      throw new RuntimeException(e);
+    } finally {
+      rollbackAndCleanup(true, null);
     }
+    return results;
   }
 
   @Override
   public List<HiveObjectPrivilege> listDBGrantsAll(String catName, String 
dbName) {
-    return listDBGrantsAll(catName, dbName, null);
+    List<HiveObjectPrivilege> results = Collections.emptyList();
+    try {
+      openTransaction();
+      results = listDBGrantsAll(catName, dbName, null);
+      commitTransaction();
+    } catch (Exception e) {
+      throw new RuntimeException(e);
+    } finally {
+      rollbackAndCleanup(true, null);

Review comment:
       rollbackAndCleanup

##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
##########
@@ -7109,22 +7121,37 @@ protected String describeResult() {
   }
 
   @Override
-  public List<HiveObjectPrivilege> listPrincipalDBGrantsAll(
-      String principalName, PrincipalType principalType) {
-    try (QueryWrapper queryWrapper = new QueryWrapper()) {
-      return convertDB(listPrincipalAllDBGrant(principalName, principalType, 
queryWrapper));
+  public List<HiveObjectPrivilege> listPrincipalDBGrantsAll(String 
principalName, PrincipalType principalType) {
+    List<HiveObjectPrivilege> results = Collections.emptyList();
+    try {
+      openTransaction();
+      results = convertDB(listPrincipalAllDBGrant(principalName, 
principalType));
+      commitTransaction();
+    } catch (Exception e) {
+      throw new RuntimeException(e);
+    } finally {
+      rollbackAndCleanup(true, null);

Review comment:
       The transaction may unable to rollback when exception happens.




----------------------------------------------------------------
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.

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