Skip to content

fix: end each transfer phase and send NDX_DEL_STATS on upstream's schedule - #8295

Merged
oferchen merged 11 commits into
masterfrom
fix/generator-phase-ndx-done
Nov 11, 2026
Merged

oferchen merged 11 commits into
masterfrom
fix/generator-phase-ndx-done

Conversation

@oferchen

@oferchen oferchen commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

Without INC_RECURSE, upstream's generator writes each phase-ending NDX_DONE as soon as the phase it closes allows. It does not wait for the sender to answer the previous one. oc held every phase end until the sender had echoed the one before, and it also put NDX_DEL_STATS at the wrong point among them.

What upstream does (generator.c, rsync 3.5.1 tarball):

None of these writes waits for an echo. The same sequence follows the per-segment NDX_DONEs under INC_RECURSE.

This reverses part of #8112. That change moved NDX_DEL_STATS one NDX_DONE earlier, on the reading that upstream sends it ahead of the NDX_DONE that ends the sender's phase loop. On the wire, 3.5.1 sends #3 before the counters, and a late delete's counters only after the sender's stats. A 3.5.1 server sender then echoes them from read_final_goodbye() after its stats (rsync.c:336-342).

Changes

  • One write plan in receiver/transfer/phases.rs: each phase-ending NDX_DONE and the NDX_DEL_STATS frame is gated on the number of sender phase NDX_DONEs read so far. The plan drives four call sites:
    • the request pass, which ends phase 0 (as before);
    • the redo pass, which now ends its phase right after its last request, or straight away when nothing needs redoing;
    • exchange_phase_done, in both the INC_RECURSE and the non-INC branch;
    • the protocol 31 goodbye, which sends a late delete's counters and NDX_DONE.
  • The pull byte-neutrality masker now accepts the sender's NDX_DEL_STATS echo between the stats and the goodbye NDX_DONE, where 3.5.1 puts it.

Evidence

The comparison used a logging TCP relay between the client and a rsync 3.5.1 tarball daemon, pulling one file with -r. Each row compares the client's writes and their order relative to the sender's NDX_DONEs.

Protocol INC_RECURSE Options oc vs 3.5.1 client
31 off none identical
31 off --delay-updates identical
31 off --delete identical
31 off --delete --delay-updates identical
31 off --delete-after identical
31 off --delete-after --delay-updates identical
30 off none identical
30 off --delay-updates identical
30 off --delete --delay-updates identical
29 off none identical
31 on none identical
31 on --delete identical
31 on --delete-delay identical

Before this change, measured on the same relay: protocol 31 without INC_RECURSE wrote one NDX_DONE per sender echo (none, --delay-updates), NDX_DEL_STATS before #3 (--delete) and before the sender's stats (--delete-after). INC_RECURSE protocol 31 (none, --delete) also waited for an echo before each NDX_DONE.

For example, at protocol 31 with --delete, 3.5.1 and oc now both write 00 00 ff02 0100000000 00 (#2, #3, DEL_STATS, #4) as soon as the sender's phase-0 NDX_DONE arrives.

Tests

  • del_stats_order_tests.rs is rewritten around a transcript that interleaves the receiver's writes with its reads of the sender's NDX_DONEs. It has five cases: early delete, early delete with --delay-updates, late delete, late delete with --delay-updates, and no delete.
  • daemon_pull_request_phase_done.rs gains a replayed-daemon test: after the sender's phase-0 NDX_DONE, the client must write the redo and delay phases' NDX_DONEs without further input. Before this change, that read blocks until the socket timeout.
  • block_stats_goodbye.rs now runs the phase exchange before the goodbye, as the receiver does.
  • daemon_pull_request_phase_done.rs also gains redo_phase_ends_right_after_its_request: the replayed daemon sends keep with a wrong file checksum and then its phase-0 NDX_DONE. The client's redo request must be followed by the redo and delay phases' NDX_DONEs before any redo reply, matching 3.5.1 on the same replay.
  • The existing redo recovery cells (verify_redo_recovers_network_paths) still pass.

Mutations, one per arm, all killed:

Gates: check_rustfmt_all.py, workspace clippy -D warnings, dead_code_census.py; transfer nextest; test-support transcript and byte-neutrality; core and bin delete, delay-updates, redo, goodbye and phase cells.

Not in this PR

  • On the redo request, oc sends item flags 0x8000 (ITEM_TRANSFER). For a destination that still does not exist, 3.5.1 sends 0xa000 (ITEM_TRANSFER | ITEM_IS_NEW, generator.c recv_generator()). It's seen on the same replay and filed separately.

Folded in: #8303 - report a failed daemon connection in upstream's words and role

When a daemon connection fails, the client now reports each address the way upstream does. Upstream's sources, all verified against 3.5.1:

  • socket.c:464-475 prints one failed to connect to %s (%s) line per address.
  • socket.c:403-406 prints an unresolvable host as getaddrinfo: %s %s: %s.
  • clientserver.c:164-165 then exits with code 10 (RERR_SOCKETIO).
  • socket.c:436-437 exits a --contimeout expiry with code 35 and the trailer only.

The role in the report follows upstream: [Receiver] for a pull or a module listing, [sender] for a push. Three #[ignore]d exit-code tests are replaced by exit_code_10_socket_io::a_refused_daemon_connection_reports_upstreams_lines, which covers pull, push and listing.

Gates on the combined tree (merge commit c81ad75): check_rustfmt_all.py, workspace clippy -D warnings and dead_code_census.py are clean. Nextest on core, cli and bin (exit_codes plus the connect, getaddrinfo, contimeout and error-report cells): 309 passed. The transfer replay and order cells: 13 passed.

Shared files

push-overlap.sh HEAD c03aed7b2 reports these overlaps. All touch different functions, apart from the progress-flush branches noted at the end:

Folded in: task 591 - redo request item flags

The phase-2 redo now sends the item flags upstream's generator gives it. Before, it always sent a bare ITEM_TRANSFER.

upstream:

  • generator.c:2667-2705: the redo re-enters recv_generator() for the redo index. That re-stats the destination (generator.c:2213-2223 reports and skips any failure except ENOENT).
  • generator.c:2378-2384: the redo request is itemized against that stat.
  • generator.c:584: the failed temp file was discarded, so a new file is still absent and goes out as ITEM_TRANSFER | ITEM_IS_NEW. An existing destination carries its size and time report bits.

redo_request_iflags (candidates.rs) stats the destination through the receiver's sandbox, folds --fake-super, reports a non-ENOENT failure with upstream's recv_generator: failed to stat line, and itemizes with the same itemize_existing_flags the first request uses.

Evidence: a replayed daemon serves keep with a wrong file checksum at protocol 30. The redo request is byte-identical to the 3.5.1 client's in both cases:

  • new file: fe0000 00a0 + empty sum head (before: fe0000 0080)
  • existing 5-byte keep with an older mtime: fe0000 0c80 + sum head with 1 block and a 16-byte strong sum

Tests in daemon_pull_request_phase_done.rs:

  • redo_phase_ends_right_after_its_request now asserts the full 3.5.1 bytes.
  • New redo_request_itemizes_an_existing_destination asserts 0x800c.

Mutation: returning a bare ITEM_TRANSFER makes both tests fail.

Known gap (task 598): with --delay-updates, and with --partial-dir, 3.5.1 keeps a file that fails verification in the partial dir (receiver.c:1318-1333) and redoes against it. Its request is 00a8 81 + a partial-dir basis, where oc sends 00a0 + no basis. oc discards the failed file instead.

The pull masker anchors on the stats rather than on frame boundaries. The sender flushes before handle_stats() (main.c:1007-1008), so the stats open a MSG_DATA frame, but with master's batched sender flush the goodbye can share that frame (io.c perform_io()). The masker now accepts exactly NDX_DONE, or the NDX_DEL_STATS echo and then NDX_DONE, after the stats.

@github-actions github-actions Bot added the bug Something isn't working label Nov 3, 2026
@oferchen oferchen closed this Nov 3, 2026
@oferchen oferchen reopened this Nov 3, 2026
@oferchen oferchen closed this Nov 3, 2026
@oferchen oferchen reopened this Nov 3, 2026
@oferchen
oferchen force-pushed the fix/generator-phase-ndx-done branch from 0ec35de to c81ad75 Compare November 4, 2026 02:08
@oferchen oferchen changed the title fix: end the request phase with NDX_DONE right after the last request fix: end each transfer phase and send NDX_DEL_STATS on upstream's schedule Nov 4, 2026
@oferchen
oferchen force-pushed the fix/generator-phase-ndx-done branch from c81ad75 to ef508ee Compare November 4, 2026 06:55
@oferchen oferchen closed this Nov 4, 2026
@oferchen oferchen reopened this Nov 4, 2026
@oferchen
oferchen force-pushed the fix/generator-phase-ndx-done branch from 3fa239f to 6ccda6f Compare November 4, 2026 08:57
@oferchen oferchen closed this Nov 10, 2026
@oferchen oferchen reopened this Nov 10, 2026
@oferchen oferchen closed this Nov 10, 2026
@oferchen oferchen reopened this Nov 10, 2026
@oferchen
oferchen force-pushed the fix/generator-phase-ndx-done branch from 7d454a3 to 373ba8e Compare November 10, 2026 08:08
@oferchen
oferchen force-pushed the fix/generator-phase-ndx-done branch from 373ba8e to 7f3531b Compare November 10, 2026 12:41
@oferchen oferchen closed this Nov 10, 2026
@oferchen oferchen reopened this Nov 10, 2026
@oferchen
oferchen force-pushed the fix/generator-phase-ndx-done branch from 700a845 to 3970c93 Compare November 10, 2026 17:45
@oferchen
oferchen force-pushed the fix/generator-phase-ndx-done branch from 3970c93 to 05744d0 Compare November 10, 2026 19:07
Without INC_RECURSE upstream's generator writes the phase-0 NDX_DONE
right after its generate loop (generator.c:2831-2833), before any reply
is read. The receiver now does the same instead of leaving it to the
finalize exchange, reads the sender's answer before the redo pass, and
then drains the hard-link follower echoes that now follow it.
open_socket_out() prints one "failed to connect to %s (%s)" line per
failed address, naming the host as given and the numeric address, from
the process that dialled: the lone Receiver for a pull or a listing,
the sender for a push (socket.c:464-475, clientserver.c:164-165). An
unresolvable host is "getaddrinfo: HOST PORT: <gai_strerror>"
(socket.c:402-406), and a --contimeout expiry exits RERR_CONTIMEOUT
before reporting any address. oc printed one line of its own for the
last address only, as [client].
@oferchen
oferchen force-pushed the fix/generator-phase-ndx-done branch from 5243e76 to b98fc65 Compare November 10, 2026 20:35
@oferchen oferchen closed this Nov 10, 2026
@oferchen oferchen reopened this Nov 10, 2026
@oferchen
oferchen merged commit eb9338f into master Nov 11, 2026
100 of 103 checks passed
@oferchen
oferchen deleted the fix/generator-phase-ndx-done branch November 11, 2026 04:59
oferchen added a commit that referenced this pull request Nov 18, 2026
#8434)

Two documentation changes for the 0.6.5 release.

**Changelog.** Every PR merged since v0.6.4 was checked against
`[Unreleased]`.
- Seven lines cited five PRs that were closed without merging; they now
cite the PRs that carried the work (#8295, #8304, #8314, #8353, #8383).
- Three lines added by #8363 were no longer in the file and are
restored.
- Eighteen merged PRs with user-visible changes had no entry and now
have one.
- One entry moved from Added to Fixed.

**Differences from rsync 3.5.2.** New
`docs/differences-from-rsync-3.5.2.md`, linked from the README and the
environment reference. It lists behaviour kept on purpose, upstream
fixes adopted early (none yet, three pending), oc-rsync extensions
(options, transports, daemon parameters, debug words, sandboxing,
environment variables, the opt-in consecutive-match extension) and links
to the platform documents. Every row is backed by code or a test.

No code changes.

Closes #8564
Closes #8565
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