Repository navigation
fix: close FileIO source before completing its IOResult - #3808
Merged
Merged
Conversation
He-Pin
marked this pull request as ready for review
November 24, 2026 03:45
This was referenced Nov 26, 2026
pjfanning
reviewed
Nov 26, 2026
pjfanning
left a comment
Member
There was a problem hiding this comment.
Looks good to me overall. I checked the open failure, read failure, EOF, cancellation, downstream failure and abrupt termination paths, and the result keeps its shape in each. One nit inline.
Motivation: Applications can use the materialized FileIO source result to coordinate later access to the file. The result could be completed before an opened channel had been closed. Modification: Attempt to close the channel before publishing the result. Log a non-fatal close error with its cause, while keeping any earlier read, open, or downstream error as the primary result. Result: Consumers can observe that the close attempt has finished. A close-only failure remains visible in the materialized IOResult status without changing the downstream terminal signal. Tests: On JDK 17, both Scala 2.13.18 and 3.3.9 passed FileSourceSpec and FileSourceCloseFailureSpec in a focused run. The new cases observe the close error log after EOF and after a previous read failure. References: FileOutputStage's close-before-result convention, PJ's review on apache#3808, and the IOResult deprecation cleanup in apache#2054.
He-Pin
force-pushed
the
file-source-close-before-io-result
branch
from
November 26, 2026 13:00
10174ca to
bf8b46e
Compare
He-Pin
added a commit
to He-Pin/incubator-pekko
that referenced
this pull request
Nov 26, 2026
Motivation: A positional file-channel read can return fewer bytes than requested without reaching EOF. Treating that as EOF could truncate the source. Modification: Keep filling the existing buffer after positive progress. Emit a full chunk, or the remaining bytes on a terminal read, without changing the read-ahead limit or materialized result and close ordering. Result: A sequence of short positive reads yields full chunks until the final chunk. The existing zero-read termination policy is unchanged. Tests: FileSourceSpec: 18 passed on Scala 2.13.18 and 3.3.9 (JDK 17), compiling the exact changed blobs against cached support classes on the apache#3808 branch. Native sbt confirmed the old implementation fails the new test. Scoped style and diff checks passed. References: Depends on apache#3808 for the channel-injection test seam.
pjfanning
approved these changes
Nov 26, 2026
pjfanning
left a comment
Member
There was a problem hiding this comment.
Thanks for logging the close failure and adding FileSourceCloseFailureSpec. LGTM, assuming CI passes on the new commit.
He-Pin
added a commit
to He-Pin/incubator-pekko
that referenced
this pull request
Nov 27, 2026
Motivation: A positional file-channel read can return fewer bytes than requested without reaching EOF. Treating that as EOF could truncate the source. Modification: Keep filling the existing buffer after positive progress. Emit a full chunk, or the remaining bytes on a terminal read, without changing the read-ahead limit or materialized result and close ordering. Result: Short positive reads yield full chunks until the final chunk. The existing zero-read termination policy is unchanged. Tests: - Native FileSourceSpec and FileSourceCloseFailureSpec: 20/20 each on Scala 2.13.18 and 3.3.9, JDK 17. - The exact pre-fix FileSource blob failed the new case, as expected, with the same Scala 2.13 test classes. - Scoped Scalafmt, license header checks and git diff --check passed. References: Refs apache#3808 and apache#3815.
He-Pin
added a commit
that referenced
this pull request
Nov 29, 2026
Motivation: A positional file-channel read can return fewer bytes than requested without reaching EOF. Treating that as EOF could truncate the source. Modification: Keep filling the existing buffer after positive progress. Emit a full chunk, or the remaining bytes on a terminal read, without changing the read-ahead limit or materialized result and close ordering. Result: Short positive reads yield full chunks until the final chunk. The existing zero-read termination policy is unchanged. Tests: - Native FileSourceSpec and FileSourceCloseFailureSpec: 20/20 each on Scala 2.13.18 and 3.3.9, JDK 17. - The exact pre-fix FileSource blob failed the new case, as expected, with the same Scala 2.13 test classes. - Scoped Scalafmt, license header checks and git diff --check passed. References: Refs #3808 and #3815.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The materialized FileIO source result can be used to decide when an input file is no longer in use. It could previously complete while the channel was still open.
Modification
Attempt to close an opened input channel before completing the materialized result. Preserve the earlier read and cancellation result shapes and add EOF and cancellation tests that directly observe a real open file channel when that result completes.
Result
Consumers can wait for the materialized result before taking the next step on the file. Both new tests observed an open channel before the fix and now pass.
Risk
This changes when the result is published, not when downstream receives data or completion. If close itself fails, the original failure still takes precedence. No Windows unlink behavior is claimed.
Tests
References
Follows FileOutputStage's close-before-result convention; the comparison with Netty #10212 surfaced this independent lifecycle issue.