Repository navigation
fix(transfer): drain stdin to EOF in SSH receiver after goodbye - #5771
Merged
Merged
Conversation
oferchen
force-pushed
the
fix/uts-v3-a-ssh-goodbye
branch
2 times, most recently
from
June 14, 2026 10:31
f1acc6b to
8b17759
Compare
UTS-v3 Cluster A surfaced four upstream testsuite failures (`batch-mode`, `alt-dest`, `daemon-gzip-download`, `daemon-refuse-compress`) all reporting "connection unexpectedly closed (N bytes received so far) [receiver]" at near-identical byte cutoffs. PR 5765 fixed the daemon-as-sender leg by dropping the half-close and adding SO_LINGER plus a TCP drain, but `alt-dest` reaches oc-rsync through the SSH transport (lsh.sh wrapping `--rsync-path=oc-rsync`), which does not flow through `daemon::sections::module_access::transfer`. The race re-surfaced on the SSH path: the upstream sender keeps writing trailing MSG_STATS / NDX_DONE bytes after our final NDX_DONE, but the `--server --receiver` process returns from `run_server_stdio` and exits immediately, closing the SSH stdio pipes. The upstream sender then sees EOF in `read_final_goodbye()` before the bytes it is still streaming reach us, and reports "connection unexpectedly closed". Upstream's receiver child mirrors this with `noop_io_until_death()` in io.c:943 - after writing its final goodbye it loops on `read_buf(iobuf.in_fd, ...)` until the parent reaps it. The threaded oc-rsync collapses receiver and generator into one process, so drain stdin to EOF in the CLI `--server` boundary instead. The upstream peer FINs its end of the pipe as part of its own `exit_cleanup`, our read returns 0, and we unblock. Gated to the receiver role: the generator (sender) side does not face this race because its peer closes its read end first. Daemon mode is unaffected because the daemon dispatches into `run_server_with_handshake` directly and runs its own TCP drain in `process_approved_module`. upstream: io.c:943-963 noop_io_until_death(), main.c:1075 receiver-child loop on read_final_goodbye(), cleanup.c:254 noop_io_until_death() call in _exit_cleanup.
oferchen
force-pushed
the
fix/uts-v3-a-ssh-goodbye
branch
from
June 14, 2026 11:18
8b17759 to
560af54
Compare
This was referenced Jun 14, 2026
oferchen
added a commit
that referenced
this pull request
Jun 14, 2026
…ocal-rsh deadlock The unbounded EOF drain added in PR #5771 to the receiver-role server exit path deadlocks on the SSH / `--rsh=fake_rsh --rsync-path=oc-rsync` transport used by the standalone interop harness. The upstream sender's `read_final_goodbye()` keeps the connection open until our stdout BufWriter is flushed and closed by process exit; the drain blocks on its EOF, and process exit cannot run until the drain returns. Each side waits on the other. This was visible on master HEAD as two `interop / interop with upstream rsync` standalone failures, both terminated by the harness `timeout 30s`: - `test_iconv_local_ssh_interop` direction-b (tools/ci/run_interop.sh:3530) - `test_compress_ssh_interop` direction-b (tools/ci/run_interop.sh:3682) Bound the drain to 250 ms via a background worker plus `recv_timeout`. Upstream's `noop_io_until_death()` (io.c:943-963) arms a 60 s `io_timeout` before its own read loop and treats EOF inside that window as a clean exit (`kluge_around_eof = 2` -> `exit_cleanup(0)` at io.c:217-232) - the same behaviour we now adopt with a tighter bound. 250 ms is comfortably above loopback round-trip and well below the 10 s upstream `--timeout` configured by the interop harness. The wire-protocol goodbye envelope itself is unchanged: only the post-envelope no-op drain becomes bounded. The cluster A regression PR #5771 was added to fix is still covered: the peer's trailing bytes arrive within microseconds of the goodbye and complete the drain naturally before the 250 ms ceiling. PR #5780 closed a 200 ms-bound proposal in favour of the deterministic half-close approach in PR #5781, but CI run 27503163030 confirmed the half-close alone still hits the same two timeouts. A bounded drain is required because the peer waits for our stdout FIN, which only fires on process exit. upstream: io.c:943-963 `noop_io_until_death()`; io.c:217-232 `whine_about_eof()` clean exit when `kluge_around_eof > 0`; cleanup.c:254 `noop_io_until_death()` call in `_exit_cleanup`.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
UTS-v3 Cluster A surfaced four upstream testsuite failures (`batch-mode`, `alt-dest`, `daemon-gzip-download`, `daemon-refuse-compress`) all reporting "connection unexpectedly closed (N bytes received so far) [receiver]" at near-identical byte cutoffs. PR 5765 fixed the daemon-as-sender leg by dropping the half-close and adding SO_LINGER plus a TCP drain, but `alt-dest` reaches oc-rsync through the SSH transport (lsh.sh wrapping `--rsync-path=oc-rsync`), which does not flow through `daemon::sections::module_access::transfer`. The race re-surfaced on the SSH path: the upstream sender keeps writing trailing MSG_STATS / NDX_DONE bytes after our final NDX_DONE, but the `--server --receiver` process returns from `run_server_stdio` and exits immediately, closing the SSH stdio pipes. The upstream sender then sees EOF in `read_final_goodbye()` before the bytes it is still streaming reach us, and reports "connection unexpectedly closed". Upstream's receiver child mirrors this with `noop_io_until_death()` in io.c:943 - after writing its final goodbye it loops on `read_buf(iobuf.in_fd, ...)` until the parent reaps it. The threaded oc-rsync collapses receiver and generator into one process, so drain stdin to EOF in the CLI `--server` boundary instead. The upstream peer FINs its end of the pipe as part of its own `exit_cleanup`, our read returns 0, and we unblock. Gated to the receiver role: the generator (sender) side does not face this race because its peer closes its read end first. Daemon mode is unaffected because the daemon dispatches into `run_server_with_handshake` directly and runs its own TCP drain in `process_approved_module`. upstream: io.c:943-963 noop_io_until_death(), main.c:1075 receiver-child loop on read_final_goodbye(), cleanup.c:254 noop_io_until_death() call in _exit_cleanup.
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
alt-destreaches oc-rsync throughlsh.sh --rsync-path=oc-rsync(SSH transport), not through the daemon. PR fix(daemon): drain peer goodbye without half-close to unblock UTS-v3 cluster A #5765 fixed the daemon-as-sender leg withSO_LINGER+ TCP drain inprocess_approved_module, but the SSH receiver path was untouched and continued to fail withconnection unexpectedly closed (2251388 bytes received so far) [receiver]at the same wire-byte signature as the daemon cluster.finalize_transferwrites its final NDX_DONE the--server --receiverprocess returns fromrun_server_stdioand exits immediately, dropping the SSH stdio pipe end. The upstream sender, still inread_final_goodbye(), sees EOF on the bytes it is still streaming and reports the cluster A diagnostic.--serverboundary for the receiver role. Mirrors upstream's receiver child which loops onread_buf(iobuf.in_fd, ...)vianoop_io_until_death()(io.c:943) until its parent reaps it. The peer FINs as part of its ownexit_cleanup, our read returns 0, and we unblock cleanly.Scope
run_server_with_handshakedirectly and continues to use the existing TCP drain indaemon::sections::module_access::transfer(PR fix(daemon): drain peer goodbye without half-close to unblock UTS-v3 cluster A #5765).--server --receiverpath picks up the new drain.Upstream reference
io.c:943-963noop_io_until_death()- receiver-side keep-reading loop.main.c:1075receiver-child loop onread_final_goodbye().cleanup.c:254noop_io_until_death()call inside_exit_cleanup.Test plan
runtests.py alt-destagainst upstream 3.4.3 and confirm the SSH-mode invocation completes withoutconnection unexpectedly closed.daemon_compress_pull_drains_peer_goodbye_for_uts_v3_cluster_a) still passes - the fix is additive and runs only on the SSH path.