Repository navigation
Conversation
The drain loop added in PR #5771 reads stdin to EOF on every receiver-role SSH server exit. The upstream sender's exit_cleanup closes its write end only after `read_final_goodbye()` has seen our NDX_DONE; if our NDX_DONE is still buffered in the outer `stdout` BufWriter when the drain starts, neither side ever closes its write end and both block in `read()`. Five tests under upstream-testsuite's lsh.sh transport hit this deadlock: alt-dest, 00-hello, ssh-basic, symlink-dirlink-basis, hardlinks. strace on the hung oc-rsync server confirms `unix_stream_data_wait` on the stdin socket fd, with the upstream client process blocked in `wait4`. Fix the deadlock with two minimal changes: * Flush `stdout` before draining so the peer's `read_final_goodbye` completes and its `exit_cleanup` can proceed. * Cap the drain wall-clock at 200ms. Sender's exit_cleanup completes within microseconds of receiving our flushed goodbye; 200ms is well above the loopback round trip and well below any runner timeout. If the peer fails to FIN within that window, exit anyway rather than hanging the test runner. upstream: io.c:943-963 noop_io_until_death(); cleanup.c:254 noop_io_until_death() call in _exit_cleanup.
Owner
Author
|
Closing in favor of the deterministic fix. The half-close (shutdown(SHUT_WR)) avoids the timer-based band-aid by signaling EOF to the peer's read_final_goodbye() directly. Re-opening in a fresh PR. |
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`.
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
PR #5771 added an unbounded stdin-drain loop on the SSH receiver exit path. Five upstream-testsuite tests under the lsh.sh transport - alt-dest, 00-hello, ssh-basic, symlink-dirlink-basis, and hardlinks - now hit a deadlock between the drain and the upstream sender's read_final_goodbye(), surfacing as 300-600s runner timeouts.
strace on the hung oc-rsync confirms
unix_stream_data_waiton stdin fd 0, with the upstream client blocked in wait4. The receiver's own NDX_DONE is still sitting in the outerstdoutBufWriter when the drain starts, so the peer'sread_final_goodbyenever completes and itsexit_cleanupnever closes its write end.Two minimal changes break the deadlock without losing the original cluster A protection:
stdoutbefore draining so the peer sees our final goodbye and proceeds withexit_cleanup.upstream: io.c:943-963
noop_io_until_death(); cleanup.c:254 noop_io_until_death() call in _exit_cleanup.Test plan