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

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

                Author: ASF GitHub Bot
            Created on: 27/Jan/22 17:45
            Start Date: 27/Jan/22 17:45
    Worklog Time Spent: 10m 
      Work Description: deniskuzZ commented on a change in pull request #2971:
URL: https://github.com/apache/hive/pull/2971#discussion_r793757325



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/Cleaner.java
##########
@@ -434,8 +437,18 @@ private boolean removeFiles(String location, 
ValidWriteIdList writeIdList, Compa
     return success;
   }
 
-  private boolean hasDataBelowWatermark(FileSystem fs, Path path, long 
highWatermark) throws IOException {
-    FileStatus[] children = fs.listStatus(path);
+  private boolean hasDataBelowWatermark(AcidDirectory acidDir, FileSystem fs, 
Path path, long highWatermark)
+      throws IOException {
+    Set<Path> acidPaths = new HashSet<>();
+    for (ParsedDelta delta : acidDir.getCurrentDirectories()) {
+      acidPaths.add(delta.getPath());
+    }
+    if (acidDir.getBaseDirectory() != null) {
+      acidPaths.add(acidDir.getBaseDirectory());
+    }
+    FileStatus[] children = fs.listStatus(path, p -> {
+      return !acidPaths.contains(p);
+    });
     for (FileStatus child : children) {
       if (isFileBelowWatermark(child, highWatermark)) {

Review comment:
       @kgyrtkirk, could you please try the following test case (simulate 
legacy behavior when CQ_NEXT_TXN_ID=NULL by commenting out 
updateWSCommitIdAndCleanUpMetadata in CompactionTxnHandler):
   ````
         @Test
     public void testReady() throws Exception {
       String dbName = "default";
       String tblName = "trfcp";
       String partName = "ds=today";
       Table t = newTable(dbName, tblName, true);
       Partition p = newPartition(t, "today");
   
       // minor compaction
       addBaseFile(t, p, 19L, 19);
       addDeltaFile(t, p, 20L, 20L, 1);
       addDeltaFile(t, p, 21L, 21L, 1);
       addDeltaFile(t, p, 22L, 22L, 1);
       burnThroughTransactions(dbName, tblName, 22);
       
       // block cleaner with an open txn
       long blockingTxn = openTxn();
       
       CompactionRequest rqst = new CompactionRequest(dbName, tblName, 
CompactionType.MINOR);
       rqst.setPartitionname(partName);
       long ctxnid = compactInTxn(rqst);
       addDeltaFile(t, p, 20, 22, 2, ctxnid);
       startCleaner();
   
       // make sure cleaner didn't remove anything, and cleaning is still queued
       List<Path> paths = getDirectories(conf, t, p);
       Assert.assertEquals("Expected 5 files after minor compaction, instead 
these files were present " + paths,
         5, paths.size());
       ShowCompactResponse rsp = txnHandler.showCompact(new 
ShowCompactRequest());
       Assert.assertEquals("Expected 1 compaction in queue, got: " + 
rsp.getCompacts(), 1, rsp.getCompactsSize());
       Assert.assertEquals(TxnStore.CLEANING_RESPONSE, 
rsp.getCompacts().get(0).getState());
   }
   ```` 
   We cannot simply filter out current and base dirs cleanup of which is 
blocked by openTxn. This is breaking the idea implemented in HIVE-24314. If 
there is a blocking open txn, retry until it's gone and we could proceed with 
cleanup. 




-- 
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: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

    Worklog Id:     (was: 716569)
    Time Spent: 3h 10m  (was: 3h)

> Enhance Compaction Cleaner to skip when there is nothing to do
> --------------------------------------------------------------
>
>                 Key: HIVE-25883
>                 URL: https://issues.apache.org/jira/browse/HIVE-25883
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Zoltan Haindrich
>            Assignee: Zoltan Haindrich
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 4.0.0
>
>          Time Spent: 3h 10m
>  Remaining Estimate: 0h
>
> the cleaner works the following way:
> * it identifies obsolete directories (delta dirs ; which doesn't have open 
> txns)
> * removes them and done
> if there are no obsolete directoris that is attributed to that there might be 
> open txns so the request should be retried later.
> however if for some reason the directory was already cleaned - similarily it 
> has no obsolete directories; and thus the request is retried for forever 



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to