[ 
https://issues.apache.org/jira/browse/HIVE-24980?focusedWorklogId=578279&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-578279
 ]

ASF GitHub Bot logged work on HIVE-24980:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 07/Apr/21 10:52
            Start Date: 07/Apr/21 10:52
    Worklog Time Spent: 10m 
      Work Description: deniskuzZ commented on a change in pull request #2156:
URL: https://github.com/apache/hive/pull/2156#discussion_r608546997



##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/CompactionTxnHandler.java
##########
@@ -891,29 +903,42 @@ public void purgeCompactionHistory() throws MetaException 
{
     ResultSet rs = null;
     List<Long> deleteSet = new ArrayList<>();
     RetentionCounters rc = null;
+    long timeoutThreshold = System.currentTimeMillis() -
+            MetastoreConf.getTimeVar(conf, 
ConfVars.COMPACTOR_HISTORY_RETENTION_TIMEOUT, TimeUnit.MILLISECONDS);
     try {
       try {
         dbConn = getDbConn(Connection.TRANSACTION_READ_COMMITTED);
         stmt = dbConn.createStatement();
         /* cc_id is monotonically increasing so for any entity sorts in order 
of compaction history,
         thus this query groups by entity and withing group sorts most recent 
first */
-        rs = stmt.executeQuery("SELECT \"CC_ID\", \"CC_DATABASE\", 
\"CC_TABLE\", \"CC_PARTITION\", \"CC_STATE\" "
-            + "FROM \"COMPLETED_COMPACTIONS\" ORDER BY \"CC_DATABASE\", 
\"CC_TABLE\", \"CC_PARTITION\", \"CC_ID\" DESC");
+        rs = stmt.executeQuery("SELECT \"CC_ID\", \"CC_DATABASE\", 
\"CC_TABLE\", \"CC_PARTITION\", "
+            + "\"CC_STATE\" , \"CC_START\", \"CC_TYPE\" "
+            + "FROM \"COMPLETED_COMPACTIONS\" ORDER BY \"CC_DATABASE\", 
\"CC_TABLE\", \"CC_PARTITION\"," +
+                "\"CC_ID\" DESC");
         String lastCompactedEntity = null;
         /* In each group, walk from most recent and count occurrences of each 
state type.  Once you
         * have counted enough (for each state) to satisfy retention policy, 
delete all other
-        * instances of this status. */
+        * instances of this status.
+        * Also, "not initiated" and "failed" compactions are cleaned up if 
they are older than
+        * metastore.compactor.history.retention.timeout and there is a newer 
"succeeded"
+        * compaction on the table and either (1) the "succeeded" compaction is 
major or (2) it is minor
+        * and the "not initiated" or "failed" compaction is also minor –– so a 
minor succeeded compaction
+        * will not cause the deletion of a major "not initiated" or "failed" 
compaction.
+        */
         while(rs.next()) {
           CompactionInfo ci = new CompactionInfo(
               rs.getLong(1), rs.getString(2), rs.getString(3),
               rs.getString(4), rs.getString(5).charAt(0));
+          ci.start = rs.getLong(6);
+          ci.type = 
TxnHandler.dbCompactionType2ThriftType(rs.getString(7).charAt(0));
           if(!ci.getFullPartitionName().equals(lastCompactedEntity)) {
             lastCompactedEntity = ci.getFullPartitionName();
-            rc = new RetentionCounters(MetastoreConf.getIntVar(conf, 
ConfVars.COMPACTOR_HISTORY_RETENTION_DID_NOT_INITIATE),
-              getFailedCompactionRetention(),
-              MetastoreConf.getIntVar(conf, 
ConfVars.COMPACTOR_HISTORY_RETENTION_SUCCEEDED));
+            rc = new RetentionCounters(
+                MetastoreConf.getIntVar(conf, 
ConfVars.COMPACTOR_HISTORY_RETENTION_DID_NOT_INITIATE),

Review comment:
       Could you please extract conf value access out of the while loop.




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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 578279)
    Time Spent: 0.5h  (was: 20m)

> Add timeout for failed and "not initiated" compaction cleanup
> -------------------------------------------------------------
>
>                 Key: HIVE-24980
>                 URL: https://issues.apache.org/jira/browse/HIVE-24980
>             Project: Hive
>          Issue Type: Improvement
>            Reporter: Karen Coppage
>            Assignee: Karen Coppage
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Clear failed and not initiated compactions from COMPLETED_COMPACTIONS that 
> are older than a week (configurable) if there already is a newer successful 
> compaction on the table/partition and either (1) the succeeded compaction is 
> major or (2) it is minor and the not initiated or failed compaction is also 
> minor –– so a minor succeeded compaction will not cause the deletion of a 
> major not initiated or failed compaction from history.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to