openinx commented on a change in pull request #1404:
URL: https://github.com/apache/iceberg/pull/1404#discussion_r486106317
##########
File path:
flink/src/main/java/org/apache/iceberg/flink/sink/IcebergFilesCommitter.java
##########
@@ -108,18 +115,25 @@ public void initializeState(StateInitializationContext
context) throws Exception
this.maxCommittedCheckpointId = INITIAL_CHECKPOINT_ID;
this.checkpointsState =
context.getOperatorStateStore().getListState(STATE_DESCRIPTOR);
+ this.jobIdState =
context.getOperatorStateStore().getListState(JOB_ID_DESCRIPTOR);
if (context.isRestored()) {
this.maxCommittedCheckpointId = getMaxCommittedCheckpointId(table,
flinkJobId);
- // In the restoring path, it should have one valid snapshot for current
flink job at least, so the max committed
- // checkpoint id should be positive. If it's not positive, that means
someone might have removed or expired the
- // iceberg snapshot, in that case we should throw an exception in case
of committing duplicated data files into
- // the iceberg table.
- Preconditions.checkState(maxCommittedCheckpointId !=
INITIAL_CHECKPOINT_ID,
- "There should be an existing iceberg snapshot for current flink job:
%s", flinkJobId);
-
- SortedMap<Long, List<DataFile>> restoredDataFiles =
checkpointsState.get().iterator().next();
- // Only keep the uncommitted data files in the cache.
-
this.dataFilesPerCheckpoint.putAll(restoredDataFiles.tailMap(maxCommittedCheckpointId
+ 1));
+
+ String oldFlinkJobId = jobIdState.get().iterator().next();
+ Preconditions.checkState(oldFlinkJobId != null && oldFlinkJobId.length()
> 0,
Review comment:
I think you mean `Strings.isNotEmpty` ?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]