vinothchandar commented on code in PR #13577:
URL: https://github.com/apache/hudi/pull/13577#discussion_r2252845881


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/metadata/HoodieBackedTableMetadataWriter.java:
##########
@@ -1810,34 +1812,39 @@ static HoodieActiveTimeline 
runPendingTableServicesOperationsAndRefreshTimeline(
    * 2. In multi-writer scenario, a parallel operation with a greater 
instantTime may have completed creating a
    * deltacommit.
    */
-  void compactIfNecessary(BaseHoodieWriteClient<?,I,?,O> writeClient, 
Option<String> latestDeltaCommitTimeOpt) {
+  void compactIfNecessary(final BaseHoodieWriteClient<?,I,?,O> writeClient, 
Option<String> latestDeltaCommitTimeOpt) {
     // IMPORTANT: Trigger compaction with max instant time that is smaller 
than(or equals) the earliest pending instant from DT.
     // The compaction planner will manage to filter out the log files that 
finished with greater completion time.
     // see BaseHoodieCompactionPlanGenerator.generateCompactionPlan for more 
details.
     HoodieTimeline metadataCompletedTimeline = 
metadataMetaClient.getActiveTimeline().filterCompletedInstants();
-    final String compactionInstantTime = dataMetaClient.reloadActiveTimeline()
+    final Option<String> requiredCompactionInstantOpt = 
dataMetaClient.reloadActiveTimeline()
         // The filtering strategy is kept in line with the rollback premise, 
if an instant is pending on DT but completed on MDT,
         // generates a compaction time smaller than it so that the instant 
could then been rolled back.
         .filterInflightsAndRequested().filter(instant -> 
metadataCompletedTimeline.containsInstant(instant.requestedTime())).firstInstant()
         // minus the pending instant time by 1 millisecond to avoid conflicts 
on the MDT.
-        .map(instant -> 
HoodieInstantTimeGenerator.instantTimeMinusMillis(instant.requestedTime(), 1L))
-        .orElse(writeClient.createNewInstantTime(false));
+        .map(instant -> 
HoodieInstantTimeGenerator.instantTimeMinusMillis(instant.requestedTime(), 1L));
 
     // we need to avoid checking compaction w/ same instant again.
     // let's say we trigger compaction after C5 in MDT and so compaction 
completes with C4001. but C5 crashed before completing in MDT.
     // and again w/ C6, we will re-attempt compaction at which point latest 
delta commit is C4 in MDT.
     // and so we try compaction w/ instant C4001. So, we can avoid compaction 
if we already have compaction w/ same instant time.
-    if 
(metadataMetaClient.getActiveTimeline().filterCompletedInstants().containsInstant(compactionInstantTime))
 {
-      LOG.info("Compaction with same {} time is already present in the 
timeline.", compactionInstantTime);
-    } else if (writeClient.scheduleCompactionAtInstant(compactionInstantTime, 
Option.empty())) {
-      LOG.info("Compaction is scheduled for timestamp {}", 
compactionInstantTime);
-      writeClient.compact(compactionInstantTime, true);
-    } else if (metadataWriteConfig.isLogCompactionEnabled()) {
-      // Schedule and execute log compaction with new instant time.
-      Option<String> scheduledLogCompaction = 
writeClient.scheduleLogCompaction(Option.empty());
-      if (scheduledLogCompaction.isPresent()) {
-        LOG.info("Log compaction is scheduled for timestamp {}", 
scheduledLogCompaction.get());
-        writeClient.logCompact(scheduledLogCompaction.get(), true);
+    if (requiredCompactionInstantOpt.map(compactionInstantTime -> 
metadataMetaClient.getActiveTimeline().filterCompletedInstants().containsInstant(compactionInstantTime)).orElse(false))
 {
+      LOG.info("Compaction with same {} time is already present in the 
timeline.", requiredCompactionInstantOpt.get());

Review Comment:
   the `orElse()` wont work ?



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