zhangyue19921010 commented on code in PR #8673:
URL: https://github.com/apache/hudi/pull/8673#discussion_r1442618373


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/StreamWriteOperatorCoordinator.java:
##########
@@ -423,25 +431,41 @@ private void initInstant(String instant) {
     if (writeClient.getConfig().getFailedWritesCleanPolicy().isLazy() && 
!WriteMetadataEvent.BOOTSTRAP_INSTANT.equals(this.instant)) {
       writeClient.getHeartbeatClient().stop(this.instant);
     }
-    // starts a new instant
-    startInstant();
+    this.instant = ckpMetadata.lastPendingInstant();
+    if (writerCurInstants.stream().allMatch(this::isLessThanCurInstant)) {
+      LOG.info("Current instant " + instant + " is new, reuse current 
instant.");
+    } else if (isBootstrapOrEmpty(this.instant) || 
writerCurInstants.stream().allMatch(i -> this.instant.equals(i))) {
+      // starts a new instant
+      startInstant();
+    } else {
+      LOG.warn("Current instant: " + this.instant + ", ignore events with 
current instants: " + writerCurInstants);
+    }
     // upgrade downgrade
     this.writeClient.upgradeDowngrade(this.instant, this.metaClient);
   }
 
-  private void handleBootstrapEvent(WriteMetadataEvent event) {
-    this.eventBuffer[event.getTaskID()] = event;
-    if (Arrays.stream(eventBuffer).allMatch(evt -> evt != null && 
evt.isBootstrap())) {
+  private boolean isLessThanCurInstant(String writerCurInstant) {

Review Comment:
   Question is why do we need to check 
`HoodieTimeline.compareTimestamps(writerCurInstant, HoodieTimeline.LESSER_THAN, 
this.instant)` here. Can you please help me understand it?



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