Skip to content

fix(receiver): abort with 11 when a commit-path backup fails - #7582

Merged
oferchen merged 1 commit into
masterfrom
fix/commit-backup-failure-is-fatal
Sep 1, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/commit-backup-failure-is-fatal

Conversation

@oferchen

@oferchen oferchen commented Sep 1, 2026

Copy link
Copy Markdown
Owner

What

A commit-path backup that cannot be placed is fatal upstream. oc treated it as a per-file skip.

Upstream

finish_transfer(), rsync.c:897-900:

if (make_backups > 0 && overwriting_basis) {
        int ok = make_backup(fname, False);
        if (!ok)
                exit_cleanup(RERR_FILEIO);
  • cleanup.c:103 - _exit_cleanup() is NORETURN, so this is an abort. The errno never enters the decision.
  • cleanup.c:113-117 - the first code handed to exit_cleanup() wins.
  • cleanup.c:210-218 - the RERR_PARTIAL fallback is guarded on exit_code == 0, so 11 outranks the 23 an accumulated got_xfer_error would otherwise produce.
  • receiver.c:452-455 - the contrasting per-file failure: a denied mkstemp() is reported and recv_files() moves on. oc already matched this one and still does.

Measured

20-file batch, existing backdated destinations, --backup-dir whose leaf mkdir is denied (mode 555 parent).

exit failures reported destination
rsync 3.5.0 11 1 of 20 all 20 unchanged
oc before 23 20 of 20 all 20 unchanged
oc after 11 1 of 20 all 20 unchanged

The exit code is the visible half; the abort is the one with consequences. Skipping and continuing keeps the receiver walking a batch whose backup area is already known to be unusable, so every later -b file proceeds on a backup that cannot be placed.

Change

drain_ready_results and drain_all_results held byte-identical copies of the continue-vs-abort decision. They now share one absorb_commit_error, which splits on the operation (the commit-op tag the error already carries) rather than on the errno.

The same tag selects RERR_FILEIO in ExitCode::from_io_error, so the usual EACCES no longer falls through the PermissionDenied => FileSelect arm and reports 3.

A fatal drain now flushes what it queued for the peer before returning. A bare ? returned ahead of emit_peer_messages, dropping the keep_backup failed: <path> line that says why the run stopped; upstream loses nothing there because _exit_cleanup() reaches io_flush(MSG_FLUSH) on its way out (cleanup.c:242-253).

Test

tests/commit_backup_failure_is_fatal.rs asserts both halves in one cell - the exit code and that the last file of the batch was never reached - plus a non-vacuity twin that transfers the whole batch through a writable --backup-dir.

Non-vacuity by mutation, each half reverted in turn:

  • abort half disabled (fatal_backup = false): "the transfer must stop at the first unplaceable backup, but it reached f19, the last file of the batch (20 of 20 files reported)" - exactly the pre-fix behaviour.
  • exit-code half disabled (mapper arm removed): left: Some(3), right: Some(11), while the abort still happens.

The cell is a pull through a real --server process, so the local side is the receiver and the path under test is the network receiver's, not the engine's local-copy executor.

Known residuals, deliberately not in scope

  • Push direction reports 12, not 11. It now stops at the first file (the half with data consequences), but the receiver lives in the remote --server process, whose fatal exit is not carried back: crates/cli/src/frontend/server/run.rs returns a flat 1 for every server error and no MSG_ERROR_EXIT is emitted anywhere, so the client grades the run by the truncated stream it observes. Fixing that is server-side exit propagation, not backup handling.
  • The local-copy executor exits 23 where upstream exits 11. It already aborts, so only the code diverges, and it does so because LocalCopyError::exit_code() maps every Io kind to 23 generically - a separate change with a much wider surface.

Verification

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings
  • cargo nextest run -p transfer --all-features - 2775 passed
  • cargo nextest run -p core --all-features - 2835 passed
  • cargo nextest run -p bin --all-features - 517 passed
  • cargo nextest run -p engine -p cli -p daemon --all-features - 10813 passed
  • tools/ci/citation_drift_audit.py - exit 0
  • tools/no_placeholders.sh - exit 0

Upstream treats an unplaceable backup as fatal, not as a per-file skip:
finish_transfer() answers `!make_backup(fname, False)` with
`exit_cleanup(RERR_FILEIO)` (rsync.c:897-900), and `_exit_cleanup()` is
NORETURN (cleanup.c:103). The errno never enters that decision - EACCES
is as fatal as anything else - and the code is 11 rather than 23 because
cleanup.c:113-117 keeps the first code handed to exit_cleanup() while the
RERR_PARTIAL fallback at cleanup.c:210-218 is guarded on `exit_code == 0`.

oc classified every permission-denied commit failure as recoverable, so a
failed backup was reported and the receiver moved to the next file, ending
the run at 23. Measured over a 20-file batch with an unwritable
--backup-dir: upstream rsync 3.5.0 reports one failure and exits 11; oc
reported all twenty and exited 23. Continuing is the half that matters -
the receiver keeps walking a batch whose backup area is known to be
unusable, so every later -b file rides on a backup that cannot be placed.

The two drain sites in the pipelined receiver were byte-identical copies of
that decision; they now share one `absorb_commit_error` that splits on the
operation rather than the errno, keeping the per-file `mkstemp` failure
(receiver.c:452-455) recoverable as before. The commit-op tag already
carried by the error also selects RERR_FILEIO in the exit-code mapper, so
the usual EACCES no longer grades as FileSelect. A fatal drain now flushes
the diagnostic it queued before returning, mirroring the io_flush() upstream
reaches on its way out (cleanup.c:242-253); a bare `?` dropped the line that
says why the run stopped.

The remote-server (push) direction stops at the first file as it should but
still reports 12: the server's fatal exit is not carried back to the client,
which is a separate gap in server exit propagation.
@github-actions github-actions Bot added the bug Something isn't working label Sep 1, 2026
@oferchen
oferchen merged commit a172b75 into master Sep 1, 2026
70 checks passed
@oferchen
oferchen deleted the fix/commit-backup-failure-is-fatal branch September 1, 2026 10:59
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