klcopp commented on a change in pull request #1592:
URL: https://github.com/apache/hive/pull/1592#discussion_r514362309



##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/CompactionTxnHandler.java
##########
@@ -281,9 +280,14 @@ public void markCompacted(CompactionInfo info) throws 
MetaException {
       try {
         dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED);
         stmt = dbConn.createStatement();
-        String s = "SELECT \"CQ_ID\", \"CQ_DATABASE\", \"CQ_TABLE\", 
\"CQ_PARTITION\", " +
-            "\"CQ_TYPE\", \"CQ_RUN_AS\", \"CQ_HIGHEST_WRITE_ID\" FROM 
\"COMPACTION_QUEUE\" " +
-            "WHERE \"CQ_STATE\" = '" + READY_FOR_CLEANING + "'";
+        /*
+         * By filtering on minOpenTxnWaterMark, we will only cleanup after 
every transaction is committed, that could see
+         * the uncompacted deltas. This way the cleaner can clean up 
everything that was made obsolete by this compaction.
+         */
+        long minOpenTxnWaterMark = getMinOpenTxnIdWaterMark(dbConn);

Review comment:
       Cleaner already knows this value, Cleaner#run calls 
CompactionTxnHandler#findMinOpenTxnIdForCleaner first, then findReadyToClean, 
so you can just pass it into findReadyToClean.
   
   (Btw findMinOpenTxnIdForCleaner doesn't filter out timed out txns like 
getMinOpenTxnIdWaterMark does, might want to change that? 
(AcidHouseKeeperService should take care of that, but who knows if it's on... 
on the other hand that's another query and would take longer))

##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
##########
@@ -1526,6 +1529,10 @@ private void 
updateWSCommitIdAndCleanUpMetadata(Statement stmt, long txnid, TxnT
     if (txnType == TxnType.MATER_VIEW_REBUILD) {
       queryBatch.add("DELETE FROM \"MATERIALIZATION_REBUILD_LOCKS\" WHERE 
\"MRL_TXN_ID\" = " + txnid);
     }
+    if (txnType == TxnType.COMPACTION) {

Review comment:
       It's not the end of the world to add the CQ_TXN_ID column, but we can 
avoid that and keep things more straightforward (i.e. keep compaction stuff out 
of generic TxnHandler and limit it to CompactionTxnHandler which was made 
specifically for updating compaction-related tables) by updating CQ_NEXT_TXN_ID 
in CompactionTxnHandler instead, and calling it straight from Worker, maybe 
right between commitTxn and markCompacted. It would be so much simpler.




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