vinothchandar commented on a change in pull request #4336:
URL: https://github.com/apache/hudi/pull/4336#discussion_r831019810



##########
File path: 
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadataWriter.java
##########
@@ -706,7 +706,20 @@ protected void 
compactIfNecessary(AbstractHoodieWriteClient writeClient, String
     }
   }
 
-  protected void doClean(AbstractHoodieWriteClient writeClient, String 
instantTime) {
+  protected void cleanIfNecessary(AbstractHoodieWriteClient writeClient, 
String instantTime) {
+    Option<HoodieInstant> lastCompletedCompactionInstant = 
metadataMetaClient.reloadActiveTimeline()
+        .getCommitTimeline().filterCompletedInstants().lastInstant();
+    if (lastCompletedCompactionInstant.isPresent()
+        && metadataMetaClient.getActiveTimeline().filterCompletedInstants()
+            
.findInstantsAfter(lastCompletedCompactionInstant.get().getTimestamp()).countInstants()
 < 3) {
+      // do not clean the log files immediately after compaction to give some 
buffer time for metadata table reader,
+      // because there is case that the reader has prepared for the log file 
readers already before the compaction completes
+      // while before/during the reading of the log files, the cleaning 
triggers and delete the reading files,
+      // then a FileNotFoundException(for LogFormatReader) or NPE(for 
HFileReader) would throw.
+
+      // 3 is a value that I think is enough for metadata table reader.

Review comment:
       what's this based on?

##########
File path: 
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadataWriter.java
##########
@@ -706,7 +706,20 @@ protected void 
compactIfNecessary(AbstractHoodieWriteClient writeClient, String
     }
   }
 
-  protected void doClean(AbstractHoodieWriteClient writeClient, String 
instantTime) {
+  protected void cleanIfNecessary(AbstractHoodieWriteClient writeClient, 
String instantTime) {
+    Option<HoodieInstant> lastCompletedCompactionInstant = 
metadataMetaClient.reloadActiveTimeline()
+        .getCommitTimeline().filterCompletedInstants().lastInstant();
+    if (lastCompletedCompactionInstant.isPresent()
+        && metadataMetaClient.getActiveTimeline().filterCompletedInstants()
+            
.findInstantsAfter(lastCompletedCompactionInstant.get().getTimestamp()).countInstants()
 < 3) {

Review comment:
       pull the `3` into a final variable?




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


Reply via email to