rkhachatryan commented on code in PR #29065:
URL: https://github.com/apache/flink/pull/29065#discussion_r3927821057
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/SequentialChannelStateReaderImpl.java:
##########
@@ -102,7 +104,16 @@ public Optional<FetchedChannelState> readInputData(
}
// stateHandler.close() (above) has flushed the filter writer and
published the
// produced spill file, so read getProducedChannelState() after
the close completes.
- return Optional.ofNullable(stateHandler.getProducedChannelState());
+ Optional<FetchedChannelState> produced =
+
Optional.ofNullable(stateHandler.getProducedChannelState());
+ published = true;
+ return produced;
+ } finally {
+ // On abort no drainer is built to release the produced state;
close it here (quietly,
+ // so it doesn't mask the original failure) to avoid orphaning its
spill files.
+ if (!published) {
+ IOUtils.closeQuietly(stateHandler.getProducedChannelState());
+ }
Review Comment:
We might as well pass `CloseableRegistry cancelables` here instead (and skip
registering `state` in the caller), right?
Not sure if interface change worth it though.
##########
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/channel/SequentialChannelStateReaderImpl.java:
##########
@@ -102,7 +104,16 @@ public Optional<FetchedChannelState> readInputData(
}
// stateHandler.close() (above) has flushed the filter writer and
published the
// produced spill file, so read getProducedChannelState() after
the close completes.
- return Optional.ofNullable(stateHandler.getProducedChannelState());
+ Optional<FetchedChannelState> produced =
+
Optional.ofNullable(stateHandler.getProducedChannelState());
+ published = true;
+ return produced;
+ } finally {
+ // On abort no drainer is built to release the produced state;
close it here (quietly,
+ // so it doesn't mask the original failure) to avoid orphaning its
spill files.
+ if (!published) {
+ IOUtils.closeQuietly(stateHandler.getProducedChannelState());
+ }
Review Comment:
Actually, is this (closeQuietly) here enough? What if an exception happens
before `stateHandler` assigns a value to `producedChannelState`?
I think a proper fix would be to either:
1. Expose some cleanupOnFailure method on `stateHandler` that'd clean up any
temporary files
2. Pass `CloseableRegistry` to `stateHandler` and use it there for all the
resources (files/state)
(1) seems more explicit to me.
WDYT?
--
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]