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


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/CompactionTxnHandler.java:
##########
@@ -1295,26 +1288,39 @@ 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)) {
-      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);
+  private void removeCompactionAndAbortRetryEntries(Connection dbConn, 
CompactionInfo info) throws MetaException, RetryException {
+    // Do not perform delete when the related records do not exist.
+    // This is valid in case of no abort retry.
+    if (info.id > 0) {
+      String query = 
DELETE_COMPACTION_AND_ABORT_RETRY_ENTRIES_FROM_COMPACTION_QUEUE;
+      // Add clause to delete abort retry records when the request is 
compaction.
+      if (!info.isAbortedTxnCleanup()) {
+        query += " OR ( \"CQ_DATABASE\" = ? " +

Review Comment:
   why OR? it's either delete by cq_id or db/tbl/part
   ````
   String query = info.id > 0 ? DELETE_COMPACTION_AND_RETRY_ENTRIES : 
DELETE_COMPACTION_ENTRIES
   ````



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