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

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

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



##########
File path: 
ql/src/test/org/apache/hadoop/hive/metastore/txn/TestCompactionTxnHandler.java
##########
@@ -340,6 +341,121 @@ private void addFailedCompaction(String dbName, String 
tableName, CompactionType
     txnHandler.markFailed(ci);
   }
 
+  private void addDidNotInitiateCompaction(String dbName, String tableName, 
String partitionName,
+          CompactionType type, String errorMessage) throws MetaException {
+    CompactionInfo ci = new CompactionInfo(dbName, tableName, partitionName, 
type);
+    ci.errorMessage = errorMessage;
+    ci.id = 0;
+    txnHandler.markFailed(ci);
+  }
+
+  private void addSucceededCompaction(String dbName, String tableName, String 
partitionName,
+          CompactionType type) throws Exception {
+    CompactionRequest rqst = new CompactionRequest(dbName, tableName, type);
+    rqst.setPartitionname(partitionName);
+    txnHandler.compact(rqst);
+    assertEquals(0, txnHandler.findReadyToClean(0, 0).size());
+    CompactionInfo ci = txnHandler.findNextToCompact("fred", WORKER_VERSION);
+    assertNotNull(ci);
+    txnHandler.markCompacted(ci);
+    txnHandler.markCleaned(ci);
+  }
+
+  @Test
+  public void testPurgeCompactionHistory() throws Exception {
+    MetastoreConf.setLongVar(conf, 
MetastoreConf.ConfVars.COMPACTOR_HISTORY_RETENTION_SUCCEEDED, 2);
+    MetastoreConf.setLongVar(conf, 
MetastoreConf.ConfVars.COMPACTOR_HISTORY_RETENTION_DID_NOT_INITIATE, 2);
+    MetastoreConf.setLongVar(conf, 
MetastoreConf.ConfVars.COMPACTOR_HISTORY_RETENTION_FAILED, 2);
+    txnHandler.setConf(conf);
+
+    String dbName = "default";
+    String tableName = "tpch";
+    String part1 = "(p=1)";
+    String part2 = "(p=2)";
+
+    // 3 successful compactions on p=1
+    addSucceededCompaction(dbName, tableName, part1, CompactionType.MAJOR);
+    addSucceededCompaction(dbName, tableName, part1, CompactionType.MAJOR);
+    addSucceededCompaction(dbName, tableName, part1, CompactionType.MAJOR);
+
+    // 3 failed on p=1
+    addFailedCompaction(dbName, tableName, CompactionType.MAJOR, part1, 
"message");
+    addFailedCompaction(dbName, tableName, CompactionType.MAJOR, part1, 
"message");
+    addFailedCompaction(dbName, tableName, CompactionType.MAJOR, part1, 
"message");
+    //4 failed on p=2
+    addFailedCompaction(dbName, tableName, CompactionType.MAJOR, part2, 
"message");
+    addFailedCompaction(dbName, tableName, CompactionType.MAJOR, part2, 
"message");
+    addFailedCompaction(dbName, tableName, CompactionType.MAJOR, part2, 
"message");
+    addFailedCompaction(dbName, tableName, CompactionType.MAJOR, part2, 
"message");
+
+    // 3 not initiated on p=1
+    addDidNotInitiateCompaction(dbName, tableName, part1, 
CompactionType.MAJOR, "message");
+    addDidNotInitiateCompaction(dbName, tableName, part1, 
CompactionType.MAJOR, "message");
+    addDidNotInitiateCompaction(dbName, tableName, part1, 
CompactionType.MAJOR, "message");
+
+    countCompactionsInHistory(13);
+
+    txnHandler.purgeCompactionHistory();
+
+    countCompactionsInHistory(8);

Review comment:
       should we check the status and tbl/part for the remained compactions 
here?




-- 
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: 578270)
    Time Spent: 20m  (was: 10m)

> 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: 20m
>  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