Skip to content

fix: skip local-copy temp, open and rename failures per file - #8285

Merged
oferchen merged 5 commits into
fix/receiver-open-per-filefrom
fix/local-copy-open-per-file
Nov 3, 2026
Merged

oferchen merged 5 commits into
fix/receiver-open-per-filefrom
fix/local-copy-open-per-file

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

A local copy that cannot create its temp file, open an --inplace destination, or rename a file into place now behaves like rsync 3.5.1. It prints the receiver's per-file FERROR_XFER line, skips that file, carries on with the next one, and exits 23. Before this change the engine aborted after the first file with its own failed to copy file wording. It also called a missing --inplace target "vanished" and exited 24.

Stacked on #8284. That PR's commit-op tag and CommitDisposition classifier move down into engine (engine::commit_failure), and transfer re-exports them, so the network receiver and the local engine decide from one place which failures skip a file and which ones abort the run.

Changes

  • engine::commit_failure (moved from transfer::temp_guard): CommitOp, attach_commit_op[_between], commit_op_failure, commit_op_destination and CommitDisposition.
    • New CommitOp::failure_line renders upstream's wording for each operation. Both receivers use it.
  • Engine tagging:
    • The named-temp create is tagged mkstemp.
    • The --inplace, --append and one-inplace partial opens are tagged open.
    • The commit rename is tagged rename, and the cross-device copy fallback is tagged copy.
  • LocalCopyError::report_skipped_commit: at the per-operand and per-directory-entry sites, a skip-file commit failure prints its line once and becomes a reported error. The run then ends with the code-23 trailer.
  • Vanished classification:
    • A NotFound only counts as vanished (exit 24) when it is untagged, i.e. it came from the source side.
    • A tagged receiver failure is never vanished. upstream says "file has vanished" only from the sender's own open (sender.c:715).
  • Direct-write retry:
    • oc's Direct write (no temp file for a new destination) has no upstream counterpart.
    • When its create fails, it now retries once through the named-temp path, which is upstream's mkstemp (receiver.c:465-468). That attempt's failure is the one reported.
    • The O_TMPFILE arm already fell back this way. Both now share open_named_temp.

Oracle (tarball 3.5.1, /home/ofer/up351/rsync-3.5.1/rsync, Linux, non-root)

Fixture: src/a src/b into dst/. The sealed directory is 0555 for the run.

cell 3.5.1 oc before oc after
mkstemp in dst 2x mkstemp "dst/.a.XXXXXX" failed: Permission denied (13), exit 23 failed to copy file 'dst/a', abort identical to 3.5.1
--temp-dir sealed 2x mkstemp "tmp/a.XXXXXX" failed, exit 23 abort after first identical
--inplace, dst sealed 2x open "dst/a" failed: No such file or directory (2), exit 23 exit 24 "vanished" identical
rename, dst sealed 2x rename "tmp/a.XXXXXX" -> "a": Permission denied (13), exit 23 abort after first identical
-r src/, --temp-dir sealed 2x mkstemp "tmp/a.XXXXXX" failed, exit 23 abort after first identical
--inplace mode 644 644 644

The only remaining difference is the trailer's program name and source location.

Tests

  • tests/receiver_open_failures_exit_23.rs:
    • Each cell now runs over both transports, push (rsh shim to a --server receiver) and local, against the same oracle lines.
    • New Walk::Recursive cell for files the directory walk reaches.
  • Unit tests:
    • a_tagged_not_found_is_a_receiver_failure_not_a_vanished_source.
    • report_skipped_commit_marks_only_per_file_commit_failures_reported.
    • failure_line_mirrors_each_upstream_rsyserr.
    • an_inner_tag_survives_an_outer_one.
  • Mutations, one per arm, each killed:
    • Skip the Direct retry: the mkstemp cell fails.
    • Classify a tagged NotFound as vanished: the unit test and the in-place cell fail.
    • Drop the per-operand report: all four operand cells fail.
    • Drop the per-directory-entry report: the recursive cell fails.

Gates

fmt, workspace clippy -D warnings, engine/transfer no-default clippy, x86_64-pc-windows-gnu check, xtask no-placeholders, nextest engine, transfer, core (11174 passed) and the e2e binary.

permission_write_denied_destination_directory used to pin the old abort (a raw Io error). It now asserts upstream's per-file outcome: the PartialTransfer summary, exit 23, and no file landed.

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 force-pushed the fix/local-copy-open-per-file branch from 6990bf9 to 91250da Compare November 3, 2026 07:24
fix: discard a file whose partial-dir cannot be created, like upstream
@oferchen
oferchen merged commit 4e010d7 into fix/receiver-open-per-file Nov 3, 2026
0 of 9 checks passed
@oferchen
oferchen deleted the fix/local-copy-open-per-file branch November 3, 2026 09:36
oferchen added a commit that referenced this pull request Nov 3, 2026
…, as upstream (#8284)

* fix: skip receiver open and rename failures per file like upstream

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).

* docs: fill CHANGELOG PR number for #8284

* fix: report a failed cross-device copy fallback as upstream copy line

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.

* fix: skip local-copy temp, open and rename failures per file

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.

* docs: fill CHANGELOG PR number for #8285

* fix: discard a file whose partial-dir cannot be created, like upstream

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.

* docs: fill CHANGELOG PR number for #8290

* fix: let a failed macOS clone fall through to the per-file temp path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant