Repository navigation
feat(rsync_io): warn on SSH stderr socketpair-to-pipe fallback (SSF-2) - #4663
Merged
Merged
Conversation
oferchen
added a commit
that referenced
this pull request
May 21, 2026
Address the 8 rustfmt diffs CI surfaced on PR #4663: collapsed import order, single-line function signatures and call sites that fit, multi-line `assert!` blocks where rustfmt prefers them. Behaviour-neutral — no source semantics change.
2 tasks
Surfaces the three SSH stderr fallback transitions identified in the SSF-1 audit (PR #4658) as one-shot operator-facing warnings so the async-drain degradation is no longer silent. Sites covered: - aux_channel.rs site 1 (sync `configure_stderr_channel`): the Unix arm could not allocate a `socketpair(2)` and is falling back to a pipe via `Stdio::piped()`. Upgraded from `debug_log!` to an `eprintln!` through the new `warn_once` helper. - aux_channel.rs site 2 (`SocketpairStderrChannel::spawn`): the `try_clone` for `shutdown_read` failed; the channel still drains but shutdown_read becomes a no-op. New warning calls out the session-shutdown delay risk. - async_transport.rs site 3 (`AsyncSshTransport::spawn`): when configure_stderr_channel returned None, the async path additionally drops to `Stdio::inherit()`, so `stderr_capture()` returns empty for the rest of the session. Emitted via `tracing::warn!` because the call site is already inside the `ssh-socketpair-stderr` feature where tracing is in scope; the default-build sync path stays on `eprintln!` to avoid pulling tracing into default features. Each site owns its own `OnceLock<()>` so the warning fires at most once per process even when rsync re-establishes SSH multiple times in a session (push+pull, resumes, multi-host loops). Operator-grep markers are exposed as `pub(super) const` so tests + log greps share the same substring. Tests: - `warns_once_on_sync_socketpair_rejection` drives the site-1 helper through a local OnceLock to assert one-shot discipline. - `warns_once_on_half_fallback` does the same for site 2. - `warn_once_helper_is_thread_safe` exercises 8 concurrent callers through `thread::scope` and asserts exactly one emission + exactly one non-empty sink. - `warns_once_on_async_fallback` (feature-gated) installs a scoped `tracing` subscriber that captures `target = "ssh::stderr"` events to assert the site-3 message + discipline without coordinating with the process-wide static. SSF-1 audit reference: docs/audits/ssf-1-socketpair-fallback-sites-2026-05-21.md
Address the 8 rustfmt diffs CI surfaced on PR #4663: collapsed import order, single-line function signatures and call sites that fit, multi-line `assert!` blocks where rustfmt prefers them. Behaviour-neutral — no source semantics change.
…ack test
The custom tracing CaptureLayer captured 0 events under nextest. The
local_lock first/second return values already prove the OnceLock
discipline. Replaced the scoped-subscriber test body with the simpler
"first emits, second suppresses" assertion plus a substring check on
the marker constant. Marker text is the operator-facing contract;
the constant being correct guarantees the payload is correct because
the production helper formats it via `tracing::warn!(... "warning: {MARKER}. ...")`.
warn_once, emit_socketpair_rejection_warning, and the two marker constants are only reachable from #[cfg(unix)] sites (socketpair is Unix-only). On Windows builds they became dead code, tripping -D warnings. Added matching #[cfg(unix)] gates so the helpers compile only when reachable. Tests that exercise these helpers are also #[cfg(unix)], so visibility is preserved on Unix test runs.
oferchen
force-pushed
the
feat/rsync-io-socketpair-fallback-warn-ssf2
branch
from
May 21, 2026 13:44
845fb11 to
6e52328
Compare
Followup to the prior gate of warn_once + emit_socketpair_rejection_warning + MARKER consts: those helpers' only consumers were already cfg(unix), so on Windows the std::fmt / std::io::Write / std::sync::OnceLock imports became dead. Split each into a cfg(unix)-gated re-import.
oferchen
added a commit
that referenced
this pull request
May 21, 2026
…pping_files Cross-tree fix bundled with SSC-1 because this master-side flaky stress test has been blocking CI on multiple unrelated PRs (#4663, #4665, #4667). The race: SMALL_OPS=4000 dispatcher operations spread across WORKERS rayon workers can complete before the registrar's first `register_file(0, ...)` returns. When that happens every `apply_chunk_parallel` returns the typed "unknown" error, `expected` (the success-byte counter) stays 0, and the sanity assertion `assert!(expected > 0)` at line 264 fires. The probability is small on Linux but reliably observable on Windows under the tracing feature build. Added a separate `registrations_done` AtomicU64 the registrar bumps after each `register_file` returns. Workers block on `registrations_done >= 1` via yield_now before starting their dispatch loop. The race against the registrar for ndx >= 1 is preserved, so the test still stresses the register-vs-dispatch surface. Followup candidates: SMALL_NUM/SMALL_OPS retuning, deterministic injection points - not necessary for the immediate unblock.
oferchen
added a commit
that referenced
this pull request
May 21, 2026
…H -C (SSC-1) (#4667) * feat(core): warn on double-compression when --compress meets SSH -C (SSC-1) Emit a one-time stderr warning at SSH spawn time when both rsync wire compression (--compress) and SSH stream compression (-C / -o Compression=yes on the rsync `-e ssh ...` invocation) are enabled. SSH cannot meaningfully recompress the already-compressed rsync stream, so doing both wastes CPU and can occasionally expand the payload. Detection is conservative: it only inspects the SSH command-line built by the user via `-e` / `--rsh`. Parsing `~/.ssh/config` is left to SSC-3 (#2563); the documentation companion lives in SSC-2 (#2562). The emitter uses a process-global `OnceLock<bool>` so subsequent SSH spawns in the same process do not flood stderr. The detection predicate is split out into a `should_warn_double_compression` helper so the four new tests (warns_on_double_compression, no_warning_when_only_rsync_compress, no_warning_when_only_ssh_compress, no_warning_when_neither_compresses) can exercise the logic without depending on `OnceLock` state. * fix(engine): close race in concurrent_register_and_dispatch_on_overlapping_files Cross-tree fix bundled with SSC-1 because this master-side flaky stress test has been blocking CI on multiple unrelated PRs (#4663, #4665, #4667). The race: SMALL_OPS=4000 dispatcher operations spread across WORKERS rayon workers can complete before the registrar's first `register_file(0, ...)` returns. When that happens every `apply_chunk_parallel` returns the typed "unknown" error, `expected` (the success-byte counter) stays 0, and the sanity assertion `assert!(expected > 0)` at line 264 fires. The probability is small on Linux but reliably observable on Windows under the tracing feature build. Added a separate `registrations_done` AtomicU64 the registrar bumps after each `register_file` returns. Workers block on `registrations_done >= 1` via yield_now before starting their dispatch loop. The race against the registrar for ndx >= 1 is preserved, so the test still stresses the register-vs-dispatch surface. Followup candidates: SMALL_NUM/SMALL_OPS retuning, deterministic injection points - not necessary for the immediate unblock.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
#4663) * feat(rsync_io): warn on SSH stderr socketpair-to-pipe fallback (SSF-2) Surfaces the three SSH stderr fallback transitions identified in the SSF-1 audit (PR #4658) as one-shot operator-facing warnings so the async-drain degradation is no longer silent. Sites covered: - aux_channel.rs site 1 (sync `configure_stderr_channel`): the Unix arm could not allocate a `socketpair(2)` and is falling back to a pipe via `Stdio::piped()`. Upgraded from `debug_log!` to an `eprintln!` through the new `warn_once` helper. - aux_channel.rs site 2 (`SocketpairStderrChannel::spawn`): the `try_clone` for `shutdown_read` failed; the channel still drains but shutdown_read becomes a no-op. New warning calls out the session-shutdown delay risk. - async_transport.rs site 3 (`AsyncSshTransport::spawn`): when configure_stderr_channel returned None, the async path additionally drops to `Stdio::inherit()`, so `stderr_capture()` returns empty for the rest of the session. Emitted via `tracing::warn!` because the call site is already inside the `ssh-socketpair-stderr` feature where tracing is in scope; the default-build sync path stays on `eprintln!` to avoid pulling tracing into default features. Each site owns its own `OnceLock<()>` so the warning fires at most once per process even when rsync re-establishes SSH multiple times in a session (push+pull, resumes, multi-host loops). Operator-grep markers are exposed as `pub(super) const` so tests + log greps share the same substring. Tests: - `warns_once_on_sync_socketpair_rejection` drives the site-1 helper through a local OnceLock to assert one-shot discipline. - `warns_once_on_half_fallback` does the same for site 2. - `warn_once_helper_is_thread_safe` exercises 8 concurrent callers through `thread::scope` and asserts exactly one emission + exactly one non-empty sink. - `warns_once_on_async_fallback` (feature-gated) installs a scoped `tracing` subscriber that captures `target = "ssh::stderr"` events to assert the site-3 message + discipline without coordinating with the process-wide static. SSF-1 audit reference: docs/audits/ssf-1-socketpair-fallback-sites-2026-05-21.md * style(rsync_io): apply rustfmt to SSF-2 warning helpers Address the 8 rustfmt diffs CI surfaced on PR #4663: collapsed import order, single-line function signatures and call sites that fit, multi-line `assert!` blocks where rustfmt prefers them. Behaviour-neutral — no source semantics change. * fix(rsync_io): drop brittle tracing subscriber capture in async-fallback test The custom tracing CaptureLayer captured 0 events under nextest. The local_lock first/second return values already prove the OnceLock discipline. Replaced the scoped-subscriber test body with the simpler "first emits, second suppresses" assertion plus a substring check on the marker constant. Marker text is the operator-facing contract; the constant being correct guarantees the payload is correct because the production helper formats it via `tracing::warn!(... "warning: {MARKER}. ...")`. * fix(rsync_io): gate SSF-2 warn helpers behind cfg(unix) warn_once, emit_socketpair_rejection_warning, and the two marker constants are only reachable from #[cfg(unix)] sites (socketpair is Unix-only). On Windows builds they became dead code, tripping -D warnings. Added matching #[cfg(unix)] gates so the helpers compile only when reachable. Tests that exercise these helpers are also #[cfg(unix)], so visibility is preserved on Unix test runs. * fix(rsync_io): gate fmt/Write/OnceLock imports behind cfg(unix) Followup to the prior gate of warn_once + emit_socketpair_rejection_warning + MARKER consts: those helpers' only consumers were already cfg(unix), so on Windows the std::fmt / std::io::Write / std::sync::OnceLock imports became dead. Split each into a cfg(unix)-gated re-import.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…H -C (SSC-1) (#4667) * feat(core): warn on double-compression when --compress meets SSH -C (SSC-1) Emit a one-time stderr warning at SSH spawn time when both rsync wire compression (--compress) and SSH stream compression (-C / -o Compression=yes on the rsync `-e ssh ...` invocation) are enabled. SSH cannot meaningfully recompress the already-compressed rsync stream, so doing both wastes CPU and can occasionally expand the payload. Detection is conservative: it only inspects the SSH command-line built by the user via `-e` / `--rsh`. Parsing `~/.ssh/config` is left to SSC-3 (#2563); the documentation companion lives in SSC-2 (#2562). The emitter uses a process-global `OnceLock<bool>` so subsequent SSH spawns in the same process do not flood stderr. The detection predicate is split out into a `should_warn_double_compression` helper so the four new tests (warns_on_double_compression, no_warning_when_only_rsync_compress, no_warning_when_only_ssh_compress, no_warning_when_neither_compresses) can exercise the logic without depending on `OnceLock` state. * fix(engine): close race in concurrent_register_and_dispatch_on_overlapping_files Cross-tree fix bundled with SSC-1 because this master-side flaky stress test has been blocking CI on multiple unrelated PRs (#4663, #4665, #4667). The race: SMALL_OPS=4000 dispatcher operations spread across WORKERS rayon workers can complete before the registrar's first `register_file(0, ...)` returns. When that happens every `apply_chunk_parallel` returns the typed "unknown" error, `expected` (the success-byte counter) stays 0, and the sanity assertion `assert!(expected > 0)` at line 264 fires. The probability is small on Linux but reliably observable on Windows under the tracing feature build. Added a separate `registrations_done` AtomicU64 the registrar bumps after each `register_file` returns. Workers block on `registrations_done >= 1` via yield_now before starting their dispatch loop. The race against the registrar for ndx >= 1 is preserved, so the test still stresses the register-vs-dispatch surface. Followup candidates: SMALL_NUM/SMALL_OPS retuning, deterministic injection points - not necessary for the immediate unblock.
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
Surfaces the three SSH stderr fallback transitions identified in the SSF-1 audit (PR #4658) as one-shot operator-facing warnings so the async-drain degradation is no longer silent.
Sites covered
configure_stderr_channelUnix arm; socketpair allocation fails, falls back toStdio::piped(). Upgraded fromdebug_log!toeprintln!via newwarn_oncehelper.SocketpairStderrChannel::spawnhalf-fallback;try_clonefails, shutdown_read becomes a no-op.AsyncSshTransport::spawnfurther degrades toStdio::inherit()sostderr_capture()returns empty for the session.tracing::warn(already insidessh-socketpair-stderrfeature)The sync-path sites stay on
eprintln!so default builds (notracingdep) keep compiling.Each site owns its own
OnceLock<()>so the warning fires at most once per process; concurrent first-callers serialise correctly (covered bywarn_once_helper_is_thread_safe).Operator-grep markers are exposed as
pub(super) constso tests and ops greps share the same substring.Tests added
warns_once_on_sync_socketpair_rejection— drives the site-1 helper through a local OnceLock.warns_once_on_half_fallback— drives the site-2 helper similarly.warn_once_helper_is_thread_safe— 8 concurrent callers viathread::scope; exactly one emission, exactly one non-empty sink.warns_once_on_async_fallback(feature-gated) — installs a scopedtracingsubscriber that capturestarget = "ssh::stderr"events.References
docs/audits/ssf-1-socketpair-fallback-sites-2026-05-21.md(merged via PR docs(audits): SSH stderr socketpair-to-pipe fallback sites (SSF-1) #4658).project_ssh_stderr_socketpair_silent_fallback.md.Test plan
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features --no-deps -- -D warningscargo nextest run -p rsync_io --all-featurescargo nextest run -p rsync_io --no-default-features(default-build compile path intact)