Repository navigation
fix: reuse TokenReader across files for zstd continuous stream compatibility - #3113
Merged
Merged
Conversation
…ibility Upstream rsync uses a single continuous zstd stream across all files in a transfer session - the sender never reinitializes its ZSTD_CCtx between files. The receiver must use the same ZSTD_DCtx across file boundaries. Previously, process_file_response_streaming() created a new TokenReader per file via ctx.config.token_reader(), allocating a fresh ZSTD_DCtx each time. The new DCtx expected a fresh zstd frame but received continuation data from the ongoing stream, causing decompression failures. Fix: create the TokenReader once in the pipeline loop and pass it to each per-file call. Between files, call token_reader.reset() which preserves the zstd DCtx while resetting per-file token state (matching upstream token.c:807-810 r_init behavior). Remove up:compress-zstd from KNOWN_FAILURES as this was the last remaining interop test failure.
oferchen
added a commit
that referenced
this pull request
Apr 5, 2026
Advertise zstd and lz4 in the capability negotiation string when their respective feature flags are enabled. Previously these algorithms were only usable via explicit --compress-choice and were intentionally excluded from auto-negotiation pending daemon receive codec validation. With PR #3113 fixing the daemon receive codec, auto-negotiation can safely select zstd/lz4 when both peers support them. The preference order matches upstream compat.c:100-112: zstd > lz4 > zlibx > zlib > none. Closes #1379, closes #1380.
- Remove unused `TokenReader` import from pipeline.rs (not needed since the type is inferred from `create_token_reader()` return value) - Fix `&mut token_reader` where `token_reader` is already `&mut TokenReader` in streaming.rs (was creating `&mut &mut TokenReader`)
3 tasks
oferchen
added a commit
that referenced
this pull request
Apr 6, 2026
Advertise zstd and lz4 in the capability negotiation string when their respective feature flags are enabled. Previously these algorithms were only usable via explicit --compress-choice and were intentionally excluded from auto-negotiation pending daemon receive codec validation. With PR #3113 fixing the daemon receive codec, auto-negotiation can safely select zstd/lz4 when both peers support them. The preference order matches upstream compat.c:100-112: zstd > lz4 > zlibx > zlib > none. Closes #1379, closes #1380.
oferchen
added a commit
that referenced
this pull request
Apr 6, 2026
Advertise zstd and lz4 in the capability negotiation string when their respective feature flags are enabled. Previously these algorithms were only usable via explicit --compress-choice and were intentionally excluded from auto-negotiation pending daemon receive codec validation. With PR #3113 fixing the daemon receive codec, auto-negotiation can safely select zstd/lz4 when both peers support them. The preference order matches upstream compat.c:100-112: zstd > lz4 > zlibx > zlib > none. Closes #1379, closes #1380.
oferchen
added a commit
that referenced
this pull request
May 1, 2026
…ibility (#3113) * fix: reuse TokenReader across files for zstd continuous stream compatibility Upstream rsync uses a single continuous zstd stream across all files in a transfer session - the sender never reinitializes its ZSTD_CCtx between files. The receiver must use the same ZSTD_DCtx across file boundaries. Previously, process_file_response_streaming() created a new TokenReader per file via ctx.config.token_reader(), allocating a fresh ZSTD_DCtx each time. The new DCtx expected a fresh zstd frame but received continuation data from the ongoing stream, causing decompression failures. Fix: create the TokenReader once in the pipeline loop and pass it to each per-file call. Between files, call token_reader.reset() which preserves the zstd DCtx while resetting per-file token state (matching upstream token.c:807-810 r_init behavior). Remove up:compress-zstd from KNOWN_FAILURES as this was the last remaining interop test failure. * style: apply cargo fmt * fix: remove unused TokenReader import and fix double-mut reference - Remove unused `TokenReader` import from pipeline.rs (not needed since the type is inferred from `create_token_reader()` return value) - Fix `&mut token_reader` where `token_reader` is already `&mut TokenReader` in streaming.rs (was creating `&mut &mut TokenReader`)
oferchen
added a commit
that referenced
this pull request
May 5, 2026
…ibility (#3113) * fix: reuse TokenReader across files for zstd continuous stream compatibility Upstream rsync uses a single continuous zstd stream across all files in a transfer session - the sender never reinitializes its ZSTD_CCtx between files. The receiver must use the same ZSTD_DCtx across file boundaries. Previously, process_file_response_streaming() created a new TokenReader per file via ctx.config.token_reader(), allocating a fresh ZSTD_DCtx each time. The new DCtx expected a fresh zstd frame but received continuation data from the ongoing stream, causing decompression failures. Fix: create the TokenReader once in the pipeline loop and pass it to each per-file call. Between files, call token_reader.reset() which preserves the zstd DCtx while resetting per-file token state (matching upstream token.c:807-810 r_init behavior). Remove up:compress-zstd from KNOWN_FAILURES as this was the last remaining interop test failure. * style: apply cargo fmt * fix: remove unused TokenReader import and fix double-mut reference - Remove unused `TokenReader` import from pipeline.rs (not needed since the type is inferred from `create_token_reader()` return value) - Fix `&mut token_reader` where `token_reader` is already `&mut TokenReader` in streaming.rs (was creating `&mut &mut TokenReader`)
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.
Summary
TokenReaderacross all files in a transfer session instead of creating a new one per file, preserving the zstdZSTD_DCtxacross file boundariesup:compress-zstdfromKNOWN_FAILURES- this was the last remaining interop test failureDetails
Root cause:
process_file_response_streaming()instreaming.rscalledctx.config.token_reader()which created a brand newTokenReader::new(Zstd)with a freshZSTD_DCtxfor every file. The new DCtx expected a fresh zstd frame header but received continuation data from the ongoing stream.Fix: Create the
TokenReaderonce in the pipeline loop (pipeline.rs) and pass it as&mut TokenReaderto each per-fileprocess_file_response_streaming()call. Between files,token_reader.reset()is called which preserves the zstd DCtx while resetting per-file token state (matching upstreamtoken.c:807-810r_initbehavior). The same change is applied to the non-streamingprocess_file_response()for consistency.Upstream reference:
token.c:807-810- zstdr_initonly resetsrx_tokento 0, never reinitializes theZSTD_DCtx.Test plan
pub use)up:compress-zstdinterop test passes (upstream rsync pushes with--compress-choice=zstdto oc-rsync daemon)