hbgstc123 commented on code in PR #8673:
URL: https://github.com/apache/hudi/pull/8673#discussion_r1444139475
##########
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:
because if all the writers see a smaller instant a, and coordinator current
pending instant is b. When a < b, then coordinator don't need and shouldn't
rollback b and start a new instant c.
If coordinator rollback b and start a new instant c, some writers maybe
writing to instant b, while coordinator think all writers will write to instant
c. This will leads to subsequent issues.
--
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]