Skip to content

fix(batch): mirror upstream batch writing, replay and option checks - #8250

Merged
oferchen merged 12 commits into
masterfrom
fix/batch-parity
Oct 29, 2026
Merged

oferchen merged 12 commits into
masterfrom
fix/batch-parity

Conversation

@oferchen

@oferchen oferchen commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Batch mode now matches upstream rsync 3.5.1:
    • -n with --write-batch or --only-write-batch creates no batch files (options.c:2280-2283).
    • The .sh here-doc writes each rule through get_rule_prefix(for_xfer=0) and lists the rule list as it stands when the script is written (batch.c:213-240, exclude.c:1540-1572, 1824-1885).
    • --read-batch reconciles its options with the batch's stream flags through one table, as check_batch_flags does (batch.c:59-162), and refuses conflicting options with upstream's text (options.c:1780-1792, 2265-2269).
    • --write-batch writes its .sh during protocol setup (compat.c:838). The script is a byte-exact copy of the original argv (batch.c:297-311). Remote batches record --iconv.
    • A filter rule containing a newline leaves the same partial .sh as 3.5.1 and exits 1 with upstream's text (batch.c:217-229). Batch open errors name the file through full_fname() (util1.c:1528).
    • Local batches set CF_ID0_NAMES and write the name of id 0 in the id lists, so the header is 81 fe like 3.5.1 (compat.c:739-740, uidlist.c:398-405).
    • --read-batch --inplace writes into the destination itself, keeping its inode. It truncates the file to the new length and makes backups by copy (receiver.c:664-671, 1212-1241; generator.c:2281-2301).
    • Under --delete-excluded, only the rules given after the option carry the s modifier, on the wire (- a, then -s b) and in the .sh (exclude.c:1478-1481). Every unsided rule is still treated as sender-only (exclude.c:1903-1913).
  • The dead native replay engine crates/batch/src/replay/ is deleted. Its tests now replay through the live --read-batch receiver, and their fixtures write real MD5 file sums plus the trailer a recording ends with.

Test plan

  • CI: fmt + clippy, nextest (stable), Windows, macOS, Linux musl.
  • tests/batch_upstream_oracle.rs (16 cells) compares oc against pinned 3.5.1 bytes, and against a live 3.5.1 when one is installed, with cross-replay in both directions. The cells cover:
    • the here-doc, the newline partial .sh, open-error paths, 81 fe header bytes, the --inplace inode, and the --delete-excluded here-doc.
  • crates/test-support/tests/delete_excluded_rule_order.rs checks the client-to-server rule bytes for a pull and a push, with oc and 3.5.1 as clients.
  • Every fix was mutation-checked, and 22 mutants were killed. One more mutant, which dropped the decoder reset on the replay's discard path, survived: no cell discards a compressed file. It is reported, not counted.
  • cargo nextest run -p batch -p core -p cli -p transfer -p protocol -p engine -p logging -p test-support --all-features

Coordination

  • Related: task 412 (dead replay engine) is closed here.
  • Left to other work: the -F listing : .rsync-filter against upstream : /.rsync-filter, and -/ abs (filters parity, task 222). Protocol-29 replay of an oc-recorded local batch (task 279).

Deliberate differences and residuals

  • Recursive local batches still lack INC_RECURSE: oc writes 81 fe where 3.5.1 writes 81 ff. Setting the bit made the header match in all six option cells. But 3.5.1 then refused to replay the batch with "invalid path from sender: sub/b" (flist.c:3230). The engine writes one flat file list, and an inc-recursive reader accepts only top-level names in the first list. Matching this needs an INC_RECURSE-segmented body, built either by the engine batch writer or by routing local --write-batch through the in-process sender and receiver, as upstream's local child does. This branch keeps the bit cleared. The full mirror, with the bit set and the incremental-recursion file list layout, is tracked as a follow-up (task 484).

Pre-merge checklist

  • Conventional commit prefix on PR title matches the change category.
  • cargo fmt --all run locally.
  • CHANGELOG.md updated.
  • Hyphens, not em-dashes.

@github-actions github-actions Bot added the bug Something isn't working label Oct 28, 2026
Carries the session_fork.rs fix from #8253 so this branch's macOS jobs stop
failing on the master test-harness race: on EPERM for our own child, SIGKILL
the leader before a blocking WNOWAIT wait, and accept a setpgid refusal when the
child already leads its own group. The content is identical to #8253, so the
two merge without conflict.
# Conflicts:
#	crates/core/src/client/config/filters.rs
#	crates/core/src/client/run/batch.rs
@oferchen
oferchen merged commit bef27e8 into master Oct 29, 2026
11 checks passed
@oferchen
oferchen deleted the fix/batch-parity branch October 29, 2026 07:26
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