SourabhBadhya commented on code in PR #4410:
URL: https://github.com/apache/hive/pull/4410#discussion_r1228299515


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/CompactionTxnHandler.java:
##########
@@ -1295,25 +1288,33 @@ private static boolean timedOut(CompactionInfo ci, 
RetentionCounters rc, long pa
             && (rc.hasSucceededMajorCompaction || 
(rc.hasSucceededMinorCompaction && ci.type == CompactionType.MINOR));
   }
 
-  private void removeAbortRetryEntries(Connection dbConn, CompactionInfo info) 
throws MetaException, RetryException {
-    LOG.debug("Going to execute update <{}>", 
DELETE_ABORT_RETRY_ENTRIES_FROM_COMPACTION_QUEUE);
-    try (PreparedStatement pStmt = 
dbConn.prepareStatement(DELETE_ABORT_RETRY_ENTRIES_FROM_COMPACTION_QUEUE)) {
+  private void removeCompactionAndAbortRetryEntries(Connection dbConn, 
CompactionInfo info) throws MetaException, RetryException {
+    String query = 
String.format(DELETE_COMPACTION_AND_ABORT_RETRY_ENTRIES_FROM_COMPACTION_QUEUE,
+            info.partName != null ? " = ? " : " IS NULL ", info.id > 0 ? " OR 
\"CQ_ID\" = ?" : "");
+    LOG.debug("Going to execute update <{}>", query);
+    try (PreparedStatement pStmt = dbConn.prepareStatement(query)) {
       pStmt.setString(1, info.dbname);
       pStmt.setString(2, info.tableName);
       if (info.partName != null) {
         pStmt.setString(3, info.partName);
-      } else {
-        // Since the type of 'CQ_PARTITION' column is varchar.
-        // Hence, setting null for VARCHAR type.
-        pStmt.setNull(3, Types.VARCHAR);
+        if (info.id > 0) {
+          pStmt.setLong(4, info.id);
+        }
+      } else if (info.id > 0) {
+        pStmt.setLong(3, info.id);
       }
       int rc = pStmt.executeUpdate();
+      if (rc < 1 && !info.isAbortedTxnCleanup()) {

Review Comment:
   > if (pStmt.executeUpdate()) < 1 && !info.isAbortedTxnCleanup())
   clearly, the update count is 0 here, so not sure how useful is to log that
   
   Removed it. Done.
   
   > why should we even call drop for abort txn if that is not a retry?
   
   Implemented. Done.



##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/CompactionTxnHandler.java:
##########
@@ -1295,25 +1288,33 @@ private static boolean timedOut(CompactionInfo ci, 
RetentionCounters rc, long pa
             && (rc.hasSucceededMajorCompaction || 
(rc.hasSucceededMinorCompaction && ci.type == CompactionType.MINOR));
   }
 
-  private void removeAbortRetryEntries(Connection dbConn, CompactionInfo info) 
throws MetaException, RetryException {
-    LOG.debug("Going to execute update <{}>", 
DELETE_ABORT_RETRY_ENTRIES_FROM_COMPACTION_QUEUE);
-    try (PreparedStatement pStmt = 
dbConn.prepareStatement(DELETE_ABORT_RETRY_ENTRIES_FROM_COMPACTION_QUEUE)) {
+  private void removeCompactionAndAbortRetryEntries(Connection dbConn, 
CompactionInfo info) throws MetaException, RetryException {
+    String query = 
String.format(DELETE_COMPACTION_AND_ABORT_RETRY_ENTRIES_FROM_COMPACTION_QUEUE,
+            info.partName != null ? " = ? " : " IS NULL ", info.id > 0 ? " OR 
\"CQ_ID\" = ?" : "");
+    LOG.debug("Going to execute update <{}>", query);
+    try (PreparedStatement pStmt = dbConn.prepareStatement(query)) {
       pStmt.setString(1, info.dbname);
       pStmt.setString(2, info.tableName);
       if (info.partName != null) {
         pStmt.setString(3, info.partName);
-      } else {
-        // Since the type of 'CQ_PARTITION' column is varchar.
-        // Hence, setting null for VARCHAR type.
-        pStmt.setNull(3, Types.VARCHAR);
+        if (info.id > 0) {
+          pStmt.setLong(4, info.id);
+        }
+      } else if (info.id > 0) {
+        pStmt.setLong(3, info.id);

Review Comment:
   Done.



-- 
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: [email protected]

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