Skip to content

fix: flush receiver writer after goodbye to close UTS-REVDD hang - #5674

Merged
oferchen merged 1 commit into
masterfrom
fix/uts-revdd-receiver-goodbye-flush
Jun 11, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/uts-revdd-receiver-goodbye-flush

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Add explicit writer.flush() after handle_goodbye() in the receiver-role finalize_transfer, mirroring upstream io_flush(FULL_FLUSH) in do_recv() at main.c:1067/1117/1123.
  • The flush tolerates early-close error kinds (BrokenPipe, ConnectionReset, UnexpectedEof, WouldBlock, ConnectionAborted) via a shared is_early_close_error predicate re-exported at the crate root; any other I/O error propagates.
  • Symmetric to the generator-side flush added in orchestrator::run by commit a3bc2cb ("explicit goodbye flush + arg rejection") so both roles drain buffered NDX_DONE frames before the transport FIN.

Why

The upstream rsync reverse-daemon-delta_test.py scenario - OLD upstream client pushing to a CURRENT oc-rsync daemon receiver - hangs at the 300s test timeout because the receiver-role finalization in crates/transfer/src/receiver/transfer/phases.rs returns with the final NDX_DONE (and any trailing multiplexed MSG_INFO frames) still sitting in the userspace writer buffer. The peer blocks on the echo that never arrives.

Upstream main.c calls io_flush(FULL_FLUSH) immediately after the receiver-side final NDX_DONE write in both do_recv() child (line 1067) and parent (lines 1117/1123) paths. We mirror that contract.

Test plan

  • New unit tests in crates/transfer/src/receiver/tests/errors_and_timeouts/finalize_flush_tests.rs:
    • finalize_transfer_proto28_flushes_after_goodbye - the final operation before return is a flush, not a write.
    • finalize_transfer_tolerates_broken_pipe_on_tail_flush - peer closing between the goodbye write and the tail flush does not surface a spurious error.
    • finalize_transfer_surfaces_non_close_errors_on_tail_flush - any non-close flush error still propagates (defense-in-depth against silently swallowing real I/O failures).
  • No regression for parallel-receive-delta, io_uring, IOCP, flat-flist, or daemon-tls - all share the same finalize_transfer exit and benefit equally from the added flush. The change is purely additive: an extra flush after the goodbye where the writer buffer is already drained by handle_goodbye in the typical case.
  • Symmetric with the generator-side fix in commit a3bc2cb (UTS-15.c): same is_early_close_error tolerance, same Rule 12 fail-loud semantics for other error kinds.

References

  • Upstream main.c:1067 - do_recv() child io_flush(FULL_FLUSH) after the receiver writes its final NDX_DONE.
  • Upstream main.c:1117 / main.c:1123 - do_recv() parent io_flush(FULL_FLUSH) after handle_stats(-1) and after the final NDX_DONE write.
  • Prior art: commit a3bc2cb added the symmetric generator-side flush in orchestrator::run.

@github-actions github-actions Bot added the bug Something isn't working label Jun 11, 2026
@oferchen
oferchen force-pushed the fix/uts-revdd-receiver-goodbye-flush branch 3 times, most recently from ef83985 to f91793c Compare June 11, 2026 18:30
… hang

The receiver-role finalization sequence in `finalize_transfer` calls
`handle_goodbye` and then returns without forcing the userspace writer
buffer to drain. The upstream rsync `reverse-daemon-delta_test.py`
scenario (OLD upstream client pushing to a CURRENT oc-rsync daemon
receiver) hangs at the 300s test timeout because the buffered final
NDX_DONE (and any trailing multiplexed MSG_INFO frames) never reach
the wire before the peer blocks awaiting the echo.

Upstream rsync calls `io_flush(FULL_FLUSH)` immediately after the
receiver-side final NDX_DONE write in both `do_recv()` child
(main.c:1067) and parent (main.c:1117/1123) paths. The generator role
already mirrors this contract in `orchestrator::run` (UTS-15.c, commit
a3bc2cb). This patch closes the same gap on the receiver side.

The added flush tolerates early-close error kinds (BrokenPipe,
ConnectionReset, UnexpectedEof, WouldBlock, ConnectionAborted) via the
shared `is_early_close_error` predicate, re-exported at the crate root
so generator and receiver share one definition. Any other I/O error
propagates, preserving Rule 12 fail-loud behaviour.

Regression coverage in `errors_and_timeouts::finalize_flush_tests`:

- `finalize_transfer_proto28_flushes_after_goodbye` - the final
  operation before return must be a flush, not a write.
- `finalize_transfer_tolerates_broken_pipe_on_tail_flush` - peer
  closing the socket between the goodbye write and the tail flush
  must not surface a spurious error.
- `finalize_transfer_surfaces_non_close_errors_on_tail_flush` - any
  non-close flush error still propagates.

No impact on the parallel-receive-delta, io_uring, IOCP, flat-flist,
or daemon-tls paths - all of them share the same `finalize_transfer`
exit and benefit equally from the added flush.
@oferchen
oferchen force-pushed the fix/uts-revdd-receiver-goodbye-flush branch from f91793c to e59c23a Compare June 11, 2026 18:32
@oferchen
oferchen merged commit a3efc92 into master Jun 11, 2026
9 checks passed
@oferchen
oferchen deleted the fix/uts-revdd-receiver-goodbye-flush branch June 12, 2026 14:39
oferchen added a commit that referenced this pull request Aug 24, 2026
… hang (#5674)

The receiver-role finalization sequence in `finalize_transfer` calls
`handle_goodbye` and then returns without forcing the userspace writer
buffer to drain. The upstream rsync `reverse-daemon-delta_test.py`
scenario (OLD upstream client pushing to a CURRENT oc-rsync daemon
receiver) hangs at the 300s test timeout because the buffered final
NDX_DONE (and any trailing multiplexed MSG_INFO frames) never reach
the wire before the peer blocks awaiting the echo.

Upstream rsync calls `io_flush(FULL_FLUSH)` immediately after the
receiver-side final NDX_DONE write in both `do_recv()` child
(main.c:1067) and parent (main.c:1117/1123) paths. The generator role
already mirrors this contract in `orchestrator::run` (UTS-15.c, commit
caa1aa4). This patch closes the same gap on the receiver side.

The added flush tolerates early-close error kinds (BrokenPipe,
ConnectionReset, UnexpectedEof, WouldBlock, ConnectionAborted) via the
shared `is_early_close_error` predicate, re-exported at the crate root
so generator and receiver share one definition. Any other I/O error
propagates, preserving Rule 12 fail-loud behaviour.

Regression coverage in `errors_and_timeouts::finalize_flush_tests`:

- `finalize_transfer_proto28_flushes_after_goodbye` - the final
  operation before return must be a flush, not a write.
- `finalize_transfer_tolerates_broken_pipe_on_tail_flush` - peer
  closing the socket between the goodbye write and the tail flush
  must not surface a spurious error.
- `finalize_transfer_surfaces_non_close_errors_on_tail_flush` - any
  non-close flush error still propagates.

No impact on the parallel-receive-delta, io_uring, IOCP, flat-flist,
or daemon-tls paths - all of them share the same `finalize_transfer`
exit and benefit equally from the added flush.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant