Skip to content

feat(rsync_io): bounded timeout on SSH goodbye phase (SSR-4) - #4820

Merged
oferchen merged 1 commit into
masterfrom
feat/ssr-4-ssh-goodbye-timeout-guard
May 23, 2026
Merged

oferchen merged 1 commit into
masterfrom
feat/ssr-4-ssh-goodbye-timeout-guard

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

What changed

  • SSH_GOODBYE_TIMEOUT: Duration = 30 s constant in rsync_io::ssh::embedded::connect, with rustdoc explaining the lower/upper bound tradeoff (too small = spurious shutdown errors on slow networks; too large = deadlocks again present as wall-clock cliffs).
  • New SshError::GoodbyePhaseTimeout { elapsed } variant.
  • New ChannelReader::wait_for_eof_with_timeout(budget) helper using std::sync::mpsc::recv_timeout with an Instant-based deadline so a stream of late chunks before a stall still surfaces a timeout within the budget.
  • crates/core/src/client/remote/embedded_ssh_transfer.rs calls the bounded wait immediately after drop(writer). The goodbye guard only fires on otherwise-successful transfers so it never masks a transfer-level diagnostic.

Why this is the SSR-4 shape

The v0.6.1 regression (anchored in docs/ssh-transport-decision-matrix.md section 5) hit the subprocess SSH wrapper. v0.6.2 fixed it by switching the russh path to be the preferred SSH transport. SSR-4 hardens that preferred path with a budget guard so a future deadlock in russh::Channel::wait() (or in the bridge task that drains it) surfaces in seconds as a typed error mapped to a sensible upstream exit code, not as a 200x throughput cliff.

Test plan

  • CI: wait_for_eof_times_out_when_bridge_stalls - holds the bridge sender open and asserts GoodbyePhaseTimeout fires within a generous upper bound (2 s) for a 50 ms budget.
  • CI: wait_for_eof_returns_ok_on_clean_drop - dropping the sender (healthy goodbye) returns Ok(()) promptly.
  • CI: wait_for_eof_drains_pending_chunks_then_times_out - chunks delivered before a stall are discarded; the budget still trips when the sender stays alive.
  • CI: all existing nextest, clippy, fmt, Windows/macOS/Linux musl matrices.

Tests use the budget as an upper bound rather than wall-clock equality so they stay deterministic under scheduling jitter.

@oferchen
oferchen force-pushed the feat/ssr-4-ssh-goodbye-timeout-guard branch from f16f273 to 571c8cf Compare May 23, 2026 20:32
@github-actions github-actions Bot added the enhancement New feature or request label May 23, 2026
@oferchen
oferchen force-pushed the feat/ssr-4-ssh-goodbye-timeout-guard branch 3 times, most recently from 9484ee2 to 6e2533d Compare May 23, 2026 20:55
Guards the russh-driven SSH session-shutdown path with a 30-second
bounded budget so a deadlocked remote channel close surfaces as a
typed `SshError::GoodbyePhaseTimeout` rather than as a multi-minute
hang. Anchors against the v0.6.1 SSH push regression (200x slowdown
vs upstream) that was fixed in PR #4154.

- Adds `SSH_GOODBYE_TIMEOUT = 30 s` constant with rationale.
- Extends `SshError` with `GoodbyePhaseTimeout { elapsed }`.
- Adds `ChannelReader::wait_for_eof_with_timeout` using
  `recv_timeout` with a wall-clock deadline.
- Wires the bounded wait into `embedded_ssh_transfer.rs` after the
  writer drop. The goodbye guard only fires on otherwise-successful
  transfers so it never masks a more informative transfer error.
- Maps a timeout to `ExitCode::Timeout` (30, RERR_TIMEOUT).
- Three deterministic unit tests using budget-as-upper-bound rather
  than wall-clock equality.
@oferchen
oferchen force-pushed the feat/ssr-4-ssh-goodbye-timeout-guard branch from 6e2533d to 9dc91a8 Compare May 23, 2026 21:30
@oferchen
oferchen merged commit 8e0c6a7 into master May 23, 2026
58 checks passed
@oferchen
oferchen deleted the feat/ssr-4-ssh-goodbye-timeout-guard branch May 23, 2026 22:04
oferchen added a commit that referenced this pull request Aug 24, 2026
Guards the russh-driven SSH session-shutdown path with a 30-second
bounded budget so a deadlocked remote channel close surfaces as a
typed `SshError::GoodbyePhaseTimeout` rather than as a multi-minute
hang. Anchors against the v0.6.1 SSH push regression (200x slowdown
vs upstream) that was fixed in PR #4154.

- Adds `SSH_GOODBYE_TIMEOUT = 30 s` constant with rationale.
- Extends `SshError` with `GoodbyePhaseTimeout { elapsed }`.
- Adds `ChannelReader::wait_for_eof_with_timeout` using
  `recv_timeout` with a wall-clock deadline.
- Wires the bounded wait into `embedded_ssh_transfer.rs` after the
  writer drop. The goodbye guard only fires on otherwise-successful
  transfers so it never masks a more informative transfer error.
- Maps a timeout to `ExitCode::Timeout` (30, RERR_TIMEOUT).
- Three deterministic unit tests using budget-as-upper-bound rather
  than wall-clock equality.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant