Skip to content

fix: make receiver temp, in-place and rename failures per-file errors, as upstream - #8284

Merged
oferchen merged 10 commits into
masterfrom
fix/receiver-open-per-file
Nov 3, 2026
Merged

oferchen merged 10 commits into
masterfrom
fix/receiver-open-per-file

Conversation

@oferchen

@oferchen oferchen commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Every receiver open or rename failure is per-file (task 238). The pipelined receiver used to skip a file only when the error was PermissionDenied. Any other errno aborted the run: ENOSPC, EROFS, ENAMETOOLONG, EISDIR, and the ENOENT an --inplace open reports. Upstream decides by the operation that failed, never by the errno. A failed temp create (receiver.c:465-468), in-place open (receiver.c:1242-1261) or rename into place (rsync.c:918-927) is an FERROR_XFER line, and the run continues to exit 23. A failed backup or close is RERR_FILEIO. That split now lives in one place, CommitDisposition::of, keyed on the CommitOp tag each raising site attaches. Two temp-create paths used to return untagged errors: a missing parent, and an exhausted name space. Both now carry the Mkstemp tag and keep the real errno.
  • open %s failed wording (task 241). In-place and device opens are tagged CommitOp::Open and print upstream's rsync: [receiver] open "<path>" failed: <errno>. They used to fall through to the mkstemp label.
  • 0600 in-place create (task 243). Both in-place open arms now create a missing destination with mode 0600, as upstream's O_WRONLY|O_CREAT, 0600 does (receiver.c:1221-1226): the path arm in fast_io::inplace_open and the sandbox-anchored openat arm. The final mode is still applied afterwards, so a finished --inplace file ends 0644 under umask 022, matching 3.5.1.

Oracle evidence

The oracle is rsync 3.5.1 built from the release tarball (rsync version 3.5.1 protocol version 33). The distro build gave identical output. The fixture pushes files a then b through a local rsh shim, so the receiver is a real --server process. The destination (or --temp-dir) is 0555. Because it is the operand directory and not a file-list entry, upstream never relaxes it to u+w. Each oc line below is byte-identical to 3.5.1's after masking the temp suffix. The upstream trailer comes from main.c and oc's from error.rs, as on every run.

cell rsync 3.5.1 oc before oc after
mkstemp (dst 0555) 2 x mkstemp "W/dst/.a.XXXXXX" failed: Permission denied (13), exit 23 same, exit 23 same, exit 23
mkstemp (--temp-dir 0555) 2 x mkstemp "W/tmp/a.XXXXXX" failed: Permission denied (13), exit 23 same, exit 23 same, exit 23
--inplace (dst 0555) 2 x open "W/dst/a" failed: No such file or directory (2), exit 23 server error: No such file or directory (os error 2), exit 3, b never tried 2 x upstream line, exit 23
rename (--temp-dir, dst 0555) 2 x rename "W/tmp/a.XXXXXX" -> "a": Permission denied (13), exit 23 same, exit 23 same, exit 23
--inplace new file, final mode 644 644 644

The --inplace cell is the live defect. The EACCES create is retried without O_CREAT (upstream's #ifdef linux arm), and the error that is reported is that arm's ENOENT. oc treated that errno as fatal.

Tests

  • tests/receiver_open_failures_exit_23.rs: one e2e cell per arm. Each asserts the exact per-file lines in file-list order, exit 23, and that nothing lands. The in-place cell is Linux-only, because its errno comes from the Linux-only retry arm. Every cell skips when run as root.
  • pipeline::receiver unit tests:
    • commit_disposition_is_decided_by_the_operation_not_the_errno: Mkstemp, Open and Rename x {EACCES, ENOSPC, EROFS, ENAMETOOLONG, EISDIR, ENOENT} skip the file; Backup and Close abort; untagged errors propagate.
    • an_inplace_open_failure_skips_the_file_with_the_open_wording: the failing file is skipped with the upstream line and the next file lands.
  • temp_guard: a_missing_temp_parent_is_a_tagged_mkstemp_failure.
  • fast_io: the_first_arm_creates_an_absent_target_owner_only, inplace_create_beneath_the_sandbox_is_owner_only.
  • The full transfer + fast_io nextest run passes: 4601 passed, 3 skipped.

Mutations, one per arm

mutation killed by
Open -> Propagate e2e in-place cell; commit_disposition...; an_inplace_open_failure...
Rename -> Propagate e2e rename cell
open wording -> mkstemp an_inplace_open_failure...
path arm create mode 0666 the_first_arm_creates_an_absent_target_owner_only
sandbox arm create mode 0666 inplace_create_beneath_the_sandbox_is_owner_only
untagged ENOENT from temp create a_missing_temp_parent_is_a_tagged_mkstemp_failure

Not changed (stated, not hidden)

  • The local-copy engine diverges much further, and this PR does not touch it. Same fixture, oc-rsync src/a src/b dst/ with dst 0555:
    • Plain copy: oc stops after the first file with failed to copy file 'W/dst/a': Permission denied (13) (code 23).
    • --inplace: oc reports file has vanished: "W/dst/a" (code 24).
    • 3.5.1 prints the same two per-file lines as the push table above and exits 23 in both modes.
    • Fixed in the stacked fix: skip local-copy temp, open and rename failures per file #8285.
  • A failed --partial-dir / --delay-updates staging-dir create (clear_partial_dir_obstruction, create_dir_all_sandboxed) is still untagged, so it stays fatal. Upstream prints Unable to create partial-dir for %s -- discarding and continues (receiver.c:1316-1321).
  • Task 523 (the staging-dir case above) is filed separately.

Task 274: done

  • Rename and copy commit failures are per-file for every errno on the pipelined receiver, because the classifier no longer looks at the errno.
  • The cross-device copy fallback in robust_rename() is now tagged CommitOp::Copy. The receiver reports it as upstream's copy %s -> "%s" (rsync.c:919-921, ret == -2), skips the file and exits 23.
  • An inner stage's tag survives the rename tag the caller wraps around it.
  • Tests:
    • a_failed_exdev_copy_is_tagged_as_a_copy_of_the_temp_onto_the_destination forces a failed copy with an injected EXDEV rename and a missing target directory.
    • a_failed_copy_fallback_is_reported_as_copy pins the classifier, the wording and the inner-tag rule.
    • Three mutations were checked, each killed: the copy tagged as a rename, the outer tag overwriting the inner one, and the copy verb rendered as rename.

Conventional commit prefix

  • fix:

Pre-merge checklist

  • Conventional commit prefix on PR title matches the change category.
  • cargo fmt --all run locally.
  • CHANGELOG.md updated (two Fixed entries, #8284 placeholders).
  • No references to internal tooling or non-human authoring aids; hyphens, not em-dashes.

Folded in

This PR now also carries #8285 (local-copy per-file open failures) and #8290 (partial-dir create discard), merged into this branch so the stack lands in one CI run.

oferchen added a commit that referenced this pull request Oct 29, 2026
@github-actions github-actions Bot added the bug Something isn't working label Oct 29, 2026
@oferchen oferchen closed this Oct 30, 2026
@oferchen oferchen reopened this Oct 30, 2026
The pipelined receiver skipped a file only when its output failed with
PermissionDenied; any other errno (ENOSPC, EROFS, EISDIR, and the ENOENT
an --inplace open reports after its no-create retry) aborted the run.
Upstream decides by the failed operation: a temp create, in-place open
or rename into place is an FERROR_XFER line and the transfer goes on to
exit 23 (receiver.c:465-468, receiver.c:1242-1261, rsync.c:918-927),
while a failed backup or close is RERR_FILEIO. The split now lives in
one classifier keyed on the CommitOp tag each raising site attaches.

In-place and device opens are tagged Open and print upstream's
"open %s failed" line, and a temp create under a missing parent keeps
its Mkstemp tag and real errno. A missing --inplace destination is
created 0600 until its final mode is applied (receiver.c:1221-1226).
robust_rename() falls back to copying when the rename crosses devices.
Upstream reports a failed copy as "copy %s -> \"%s\"" (rsync.c:919-921,
ret == -2) and moves on to the next file. The copy failure is now tagged
CommitOp::Copy, which the per-file classifier skips and the receiver
renders with the copy verb; an inner stage tag survives the rename tag
the caller wraps around it.
@oferchen
oferchen force-pushed the fix/receiver-open-per-file branch from 9cd0712 to bc95ae9 Compare November 3, 2026 07:09
A local copy that could not create its temp file, open an --inplace
destination or rename a file into place aborted after the first file
with its own wording, and a missing --inplace target was reported as
vanished (exit 24). rsync 3.5.1 prints the receiver line for each file
(receiver.c:465-468, receiver.c:1242-1261, rsync.c:918-927) and ends
with exit 23.

Move the commit-op tag and CommitDisposition classifier into engine so
the network receiver and the local engine share one decision and one
wording (CommitOp::failure_line). The engine tags its mkstemp, open,
rename and copy sites, reports skip-file failures at the per-operand
and per-entry sites, and counts NotFound as vanished only when it is
untagged. The oc-only Direct write retries a failed create once through
the named temp path, so the reported failure is upstream mkstemp one.
A receiver that could not create the --delay-updates / --partial-dir
staging directory for a completed file aborted the whole run (exit 23
on a local copy, exit 3 on a push). rsync 3.5.1 prints "Unable to
create partial-dir for %s -- discarding completed file.", unlinks the
temp and moves on (receiver.c:1318-1325); the line is a plain FERROR,
so the exit code is unchanged.

Tag the staging-dir create with CommitOp::PartialDir in both receivers
and classify it as the new CommitDisposition::Discard: the network
receiver sends the line as MSG_ERROR without counting a skipped file,
and the local engine reports it and resolves the entry to success.
@oferchen oferchen closed this Nov 3, 2026
@oferchen oferchen reopened this Nov 3, 2026
fix: discard a file whose partial-dir cannot be created, like upstream
fix: skip local-copy temp, open and rename failures per file
@oferchen
oferchen merged commit b72d1b3 into master Nov 3, 2026
62 of 82 checks passed
@oferchen
oferchen deleted the fix/receiver-open-per-file branch November 3, 2026 12:54
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