Skip to content

fix: emit NDX_DEL_STATS in daemon-receive goodbye for --delete pushes - #5536

Closed
oferchen wants to merge 3 commits into
masterfrom
fix/uts-6-ndx-del-stats-daemon-upload
Closed

oferchen wants to merge 3 commits into
masterfrom
fix/uts-6-ndx-del-stats-daemon-upload

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Adds NDX_DEL_STATS emission to the receiver's goodbye handshake so daemon-receive (push with --delete --stats) transfers correctly deliver per-type deletion counters back to the sender.
  • Mirrors upstream's generator path: protocol 31+ gates plus the existing early/late do_stats && delete_mode conditions used by crate::generator's should_send_del_stats.
  • Stashes the receiver's delete stats from run_pipelined so they are available when handle_goodbye writes the final NDX frames.

Upstream Reference

  • generator.c:2376-2381 early write_del_stats() path
  • generator.c:2420-2425 late write_del_stats() path
  • main.c:225-238 write_del_stats() wire format
  • rsync.c:337-342 read_ndx_and_attrs() consumes NDX_DEL_STATS

Test plan

  • Added goodbye_del_stats_tests.rs covering:
    • Protocol 31 emits NDX_DEL_STATS + 5 varints + NDX_DONE, then echo NDX_DONE.
    • Protocol 31 suppresses emission when do_stats=false.
    • Late delete (--delete-delay / --delete-after) emits on do_stats alone.
    • Protocol 30 never emits the message (upstream protocol guard).
    • Varint field order matches upstream main.c:225-238.
  • CI: fmt+clippy, nextest (stable), Windows, macOS, Linux musl, interop.

The receiver's goodbye handshake previously never emitted NDX_DEL_STATS,
so daemon-receive (push with --delete --stats) transfers could not deliver
per-type deletion counters back to the sender. Upstream's generator
writes the message in both early (generator.c:2376-2381) and late
(generator.c:2420-2425) paths gated on INFO_GTE(STATS, 2); the sender
decodes them via read_ndx_and_attrs() (rsync.c:337-342).

The receiver subsumes the generator in this codebase, so the emission is
added to ReceiverContext::handle_goodbye() under matching conditions:
protocol >= 31, do_stats, plus delete-mode-aware gating that mirrors the
existing generator-side should_send_del_stats() logic. pipelined.rs now
stashes the post-delete stats so they are available at goodbye time.

Adds unit coverage for emission on early delete, suppression without
--stats, late-delete behaviour, the protocol 30 guard, and the varint
field order required by upstream main.c:225-238.
@github-actions github-actions Bot added the bug Something isn't working label Jun 10, 2026
The handle_goodbye receiver phase uses W: Write + ?Sized so it can be
called with trait object writers, but DeleteStats::write_to required an
implicit Sized bound, breaking compilation when the receiver attempts to
emit NDX_DEL_STATS during the daemon-receive goodbye exchange.

Relax the bound to W: Write + ?Sized, matching the write_varint helper
it delegates to.
oferchen added a commit that referenced this pull request Jun 10, 2026
Group PRs #5510, #5516, #5519, #5520, #5523, #5525-#5544 by shared root
cause rather than by Stream bucket. Seven clusters surface; the parser-
stores-string and field-vs-method shadowing clusters cover the largest
share of the series, and the receiver-driver wiring-parity gap explains
the NDX_DEL_STATS goodbye misses in both #5536 and #5542. Includes a
defense-in-depth audit mapping each cluster onto the rust-landlock
ruleset wired at crates/fast_io/src/landlock.rs.

Doc-only; no code paths touched.
oferchen added a commit that referenced this pull request Jun 10, 2026
Group PRs #5510, #5516, #5519, #5520, #5523, #5525-#5544 by shared root
cause rather than by Stream bucket. Seven clusters surface; the parser-
stores-string and field-vs-method shadowing clusters cover the largest
share of the series, and the receiver-driver wiring-parity gap explains
the NDX_DEL_STATS goodbye misses in both #5536 and #5542. Includes a
defense-in-depth audit mapping each cluster onto the rust-landlock
ruleset wired at crates/fast_io/src/landlock.rs.

Doc-only; no code paths touched.
The goodbye_del_stats unit tests hard-coded NDX_DONE as the 4-byte
little-endian sequence used by the legacy NDX codec (protocol < 30).
Protocols 30 and 31 use the modern codec, which encodes NDX_DONE as
a single zero byte. The hard-coded fixtures therefore produced wire
data that the receiver decoded as `-256` instead of `-1`, failing on
every feature-combo cell that compiled the transfer crate.

Route both the synthetic sender input and the assertion-side decoder
through `create_ndx_codec(protocol)` so the test inputs and outputs
match whichever codec the receiver actually uses, mirroring the
pattern already established by `legacy_goodbye_tests`. No production
code is touched.
@oferchen

Copy link
Copy Markdown
Owner Author

Superseded by #5520, which already addresses UTS-6 (#3569 daemon-delete-stats) at the correct layer. #5520 wires --stats into ServerConfig.do_stats so the existing generator-side goodbye emitter in crates/transfer/src/generator/transfer/goodbye.rs (should_send_del_stats + write_del_stats) fires for daemon-receive pushes. This PR added emission in the receiver's handle_goodbye, but the generator owns NDX_DEL_STATS emission in this codebase (the receiver-side phases.rs only consumes the sender-echoed frame). Same supersession pattern as #5535. Closing without merge.

@oferchen oferchen closed this Jun 10, 2026
@oferchen
oferchen deleted the fix/uts-6-ndx-del-stats-daemon-upload branch June 10, 2026 14:47
oferchen added a commit that referenced this pull request Aug 24, 2026
Group PRs #5510, #5516, #5519, #5520, #5523, #5525-#5544 by shared root
cause rather than by Stream bucket. Seven clusters surface; the parser-
stores-string and field-vs-method shadowing clusters cover the largest
share of the series, and the receiver-driver wiring-parity gap explains
the NDX_DEL_STATS goodbye misses in both #5536 and #5542. Includes a
defense-in-depth audit mapping each cluster onto the rust-landlock
ruleset wired at crates/fast_io/src/landlock.rs.

Doc-only; no code paths touched.
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