Guosmilesmile commented on code in PR #18303:
URL: https://github.com/apache/iceberg/pull/18303#discussion_r4408248312
##########
flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/DynamicWriteResultAggregator.java:
##########
@@ -72,21 +86,41 @@ class DynamicWriteResultAggregator
private transient Map<String, Tuple2<ManifestOutputFileFactory, Integer>>
outputFileFactoriesAndFormatVersions;
private transient String flinkJobId;
+ private transient String sinkId;
+ private transient ListState<String> sinkIdState;
private transient String operatorId;
private transient int subTaskId;
private transient int attemptId;
private transient Catalog catalog;
- DynamicWriteResultAggregator(CatalogLoader catalogLoader, int
cacheMaximumSize) {
+ DynamicWriteResultAggregator(
+ CatalogLoader catalogLoader, int cacheMaximumSize, String initialSinkId)
{
this.catalogLoader = catalogLoader;
this.cacheMaximumSize = cacheMaximumSize;
+ this.initialSinkId = initialSinkId;
}
@Override
public void initializeState(StateInitializationContext context) throws
Exception {
context
.getRestoredCheckpointId()
.ifPresent(checkpointId -> this.lastCheckpointId = checkpointId);
+
+ this.sinkIdState =
context.getOperatorStateStore().getUnionListState(SINK_ID_DESCRIPTOR);
+ if (!CheckpointingOptions.isCheckpointingEnabled(
+ getContainingTask().getEnvironment().getJobConfiguration())) {
+ this.sinkId = getContainingTask().getEnvironment().getJobID().toString();
+ } else {
+ this.sinkId = Iterables.getFirst(sinkIdState.get(), initialSinkId);
Review Comment:
Originally, I wanted to ensure that the sinkId would remain unchanged even
after a savepoint restart, which is why I added this state. Now, we can
simplify this part.
--
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]