Repository navigation
fix(download): stop the merge pump waiting on a destroyed stream - #8
Closed
chenrui333 wants to merge 1 commit into
Closed
chenrui333 wants to merge 1 commit into
chenrui333 wants to merge 1 commit into
Conversation
The first download of an unmerged entry tees its parts into the client response and the background merge upload. A destroyed stream returns false from write() and never emits 'drain' (nor 'error' when destroyed without one), so the pump parks forever when: - the merge upload fails: `download()` destroys the merger stream, and the client's download stalls mid-body until the client times out; - the client hangs up while the pump waits on the merger: the next write to the destroyed response stream parks the pump, the merge never completes, and its lease keeps renewing. Either way the current part's backend read stays open (one S3 socket per occurrence), so enough of them fill the S3 socket pool. Wait for 'drain' or 'close', skip destroyed sinks, keep feeding the one that is still open, and stop reading once both are gone so `streamParts` destroys the current part stream. The regression tests fail on the previous pump with the filesystem and S3 drivers: the merge never settles after the client leaves, the client never finishes after the merge upload fails, and the part stream is never destroyed when both are gone. Signed-off-by: Rui Chen <rui@chenrui.dev>
Owner
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Owner
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Owner
Author
|
Superseded by upstream v9.10.0 (falcondev-oss#296). |
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.
The first download of an unmerged entry tees its parts into the client response and the background merge upload (
pumpPartsToStreams). The pump only waits for'drain', but a destroyed stream returnsfalsefromwrite()and never emits'drain'(nor'error'when it is destroyed without one), so the pump parks forever when:download()destroys the merger stream without an error, so the client's download stalls mid-body until the client gives up;In both cases the current part's backend read stays open (one S3 socket each), so enough of them fill the S3 agent's socket pool and every other request queues behind it.
This PR waits for
'drain'or'close', skips destroyed sinks, keeps feeding whichever sink is still open, and stops reading once both are gone sostreamPartsreleases the current part. falcondev-oss#282 and falcondev-oss#291 changed the route side; the pump itself was untouched.Test
tests/download-merge-sink-gone.test.tscovers the three cases against the realStorage:devAll three fail on
devand pass here with both the filesystem and S3 (RustFS) drivers.pnpm test:run(sqlite + filesystem): 24 files, 67 tests pass, 5 skipped as ondev.type-check, eslint and prettier are clean.Notes
pump_partsdrops a side whose receiver is gone;keeps_merging_after_the_client_goes_away). This is the equivalent fix for the current TypeScript server.gc()is left alone here; it is a separate PR.