You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "lrsb (via GitHub)" <gi...@apache.org> on 2026/04/21 12:33:33 UTC

Re: [PR] Flink: Fix duplicate commits when Flink jobId changes on restart [iceberg]

lrsb commented on code in PR #16011:
URL: https://github.com/apache/iceberg/pull/16011#discussion_r3117422415


##########
flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/DynamicWriteResultAggregator.java:
##########
@@ -76,10 +86,29 @@ class DynamicWriteResultAggregator
     this.cacheMaximumSize = cacheMaximumSize;
   }
 
+  @Override
+  public void initializeState(StateInitializationContext context) throws Exception {
+    super.initializeState(context);
+    this.jobIdState = context.getOperatorStateStore().getListState(JOB_ID_DESCRIPTOR);
+    Iterable<String> restoredJobIds = jobIdState.get();
+    if (restoredJobIds != null && restoredJobIds.iterator().hasNext()) {
+      String restoredJobId = restoredJobIds.iterator().next();
+      if (restoredJobId != null && !restoredJobId.isEmpty()) {
+        this.flinkJobId = restoredJobId;
+        LOG.info(
+            "Restored aggregator flink job id {} from operator state. Subsequent committables will"
+                + " be stamped with this id to keep DynamicCommitter dedup stable across restarts.",
+            restoredJobId);
+      }
+    }
+  }
+
   @Override
   public void open() throws Exception {
-    this.flinkJobId = getContainingTask().getEnvironment().getJobID().toString();
-    this.operatorId = getOperatorID().toString();
+    if (this.flinkJobId == null) {

Review Comment:
   Proposed a new implementation



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org