Guosmilesmile commented on code in PR #18123:
URL: https://github.com/apache/iceberg/pull/18123#discussion_r4124603182


##########
flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/sink/IcebergCommitter.java:
##########
@@ -138,8 +141,11 @@ public void 
commit(Collection<CommitRequest<IcebergCommittable>> commitRequests)
     }
 
     IcebergCommittable last = 
commitRequestMap.lastEntry().getValue().getCommittable();
+    // A stateless start has no committed checkpoints; the table's mark would 
drop every commit.
     long maxCommittedCheckpointId =
-        SinkUtil.getMaxCommittedCheckpointId(table, last.jobId(), 
last.operatorId(), branch);
+        restored

Review Comment:
   If the commit has already been written to the Iceberg table but the 
committable is replayed, maxCommitted > restoredCheckpointId would result in 
-1, which could cause the commit to be retried and lead to duplicate data.
   
   Maybe we should use min here instead?
   ```
   long maxCommitted =
       restoredCheckpointId == INITIAL_CHECKPOINT_ID
           ? INITIAL_CHECKPOINT_ID
           : Math.min(maxCommitted, restoredCheckpointId);
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to