Repository navigation
test: pin --read-batch -aH hardlink cluster reconstruction - #7956
Merged
Merged
Conversation
Add an oracle-free regression test for the batch hardlink data-loss fix (#7928, "ship hardlink payload under the sorted-first cluster NDX"). A local --write-batch builds the flist and delta stream in traversal order, then remaps each delta NDX to the sorted position the replaying receiver assigns after flist_sort_and_clean(). The engine's reorder_hardlink_group_holders promotes the name-sorted-last fresh cohort member to the data-holder, so it records the single payload, while the replaying receiver flags the name-sorted-first member and expects the payload under its NDX (upstream hlink.c:113-194 match_gnums()). Before #7928 the payload shipped under the holder's own sorted NDX, so the real leader received no data, was never written, and the other member was left unlinked - the cluster replayed as a single or missing file at exit 0. The only prior coverage (replay_hardlink_pair_parity in tests/batch_replay_upstream_parity.rs) skips whenever no upstream rsync oracle is installed, so a build without one has no hardlink-batch guard at all. This test drives oc's own --write-batch then --read-batch with no upstream dependency, so it always runs its assertions. The cohort names are chosen so the sorted-first member (aaa_leader.txt) is not the data-holder (zzz_holder.txt) - the exact case #7928 fixes; a same-order cohort would pass against the pre-fix code and prove nothing. Reverting the one-line emit-NDX remap makes the test fail with "replay must produce the sorted-first member aaa_leader.txt" at exit 0, confirming the guard is not vacuous. The fix lives on the write path in crates/engine, which the batch crate cannot reach (no engine dependency), so the regression is pinned by a full write -> read round-trip at the integration level rather than a batch-crate unit test.
oferchen
enabled auto-merge (squash)
September 24, 2026 14:18
oferchen
added a commit
that referenced
this pull request
Sep 24, 2026
Cross-implementation hardlink batch replay was broken both directions - a
fidelity obligation, since a batch is a tee of the protocol-32 wire stream
and the rsync man page requires any reader at protocol >= writer to replay
it. Upstream reading an oc batch failed with exit 23; oc reading an upstream
batch silently dropped the cluster leader at exit 0 (data loss). A plain
network -H transfer was unaffected in both directions.
Root cause: for a hardlink cluster upstream transfers the sorted-LAST member
- the one match_gnums() flags FLAG_HLINK_LAST and finish_hard_link()
completes - and links every other member (including the sorted-first) to it
(hlink.c:113-194, hlink.c:496-565). oc's --write-batch shipped the cluster's
single payload under the sorted-FIRST member's NDX, and the batch-replay
receiver treated the sorted-first hlink_first member as the materialized
data-holder. oc-self replay agreed with itself, so the divergence surfaced
only across implementations. The live wire path is unaffected because oc's
generator makes hlink_first the transferred member; only a recorded batch
stream can place the data-holder on a different member.
Three aligned changes:
- Writer (engine local_copy batch): ship the cluster payload under the
sorted-LAST member's NDX, matching upstream's FLAG_HLINK_LAST data-holder,
so upstream can replay an oc batch.
- Receiver replay commit (transfer receiver/transfer/replay.rs): record the
just-committed hardlink member as its group's data-holder in the
HardlinkApplyTracker. Which member the batch transferred is stream-dictated
(now the sorted-last member), so the source cannot be inferred from disk
presence - a stale pre-existing sorted-first member would otherwise win and
the fresh payload be discarded.
- Receiver create_hardlinks(): during batch replay only (self.local_replay),
let every hlink member - including the sorted-first leader - resolve its
group source through promote_hardlink_leader() (which returns the recorded
data-holder) and the self-link guard, so an absent or stale sorted-first
member is re-linked to the fresh data-holder. The live path is unchanged:
there an absent hlink_first member means its own transfer was
skipped/errored (FLAG_SKIP_HLINK) and must not be resurrected, so that path
keeps skipping every hlink_first member. This keeps the network -H receiver
and its skip/virtual-first semantics untouched.
Un-ignores cross_impl_hardlink_batch_{pair,triple}_parity (added earlier as a
registered known divergence); they now pass both directions for 2- and
3-member clusters. Fixes the UTS batch-only-remove-source-regression cell
(replay into a pre-existing destination whose stale cluster members must be
re-linked to the freshly transferred payload). oc-self #7956/#7928 stay green
(they assert end state, which survives the data-holder change).
upstream: hlink.c:113-194 match_gnums(), hlink.c:496-565 finish_hard_link().
oferchen
added a commit
that referenced
this pull request
Sep 24, 2026
* test: register cross-impl hardlink batch replay divergence Add oracle-gated cross-implementation --read-batch -aH parity cases for a 2- and 3-member hardlink cluster, both directions (upstream-writes/oc-reads and oc-writes/upstream-reads). They assert the correct upstream-matching end state: every cluster member present, all sharing one inode with the right nlink, and the unlinked control independent. Both are #[ignore]'d as a registered, owned known divergence (task #18): oc's --write-batch ships the cluster's single payload under the sorted-first member's NDX (the oc-self convention from #7928), while upstream ships it under the sorted-last member - the FLAG_HLINK_LAST data-holder its generator transfers (hlink.c:113-194 match_gnums(), hlink.c:490-565 finish_hard_link()), and oc's batch replay decodes the follower's first_hlink_ndx with a different base. So oc reading an upstream batch silently drops the leader (exit 0) and upstream reading an oc batch exits 23. A plain network -H transfer is unaffected - oc's live wire receiver follows the sender's chosen data-holder correctly - so the divergence is specific to the batch write and batch-replay paths, not the shared receiver. These tests un-ignore when the batch-path fix lands (task #18); until then they keep the verified divergence visible without a silent waiver. The oc-self replay_hardlink_pair_parity case stays non-ignored and green. * fix(batch): replay hardlinks under the sorted-last data-holder Cross-implementation hardlink batch replay was broken both directions - a fidelity obligation, since a batch is a tee of the protocol-32 wire stream and the rsync man page requires any reader at protocol >= writer to replay it. Upstream reading an oc batch failed with exit 23; oc reading an upstream batch silently dropped the cluster leader at exit 0 (data loss). A plain network -H transfer was unaffected in both directions. Root cause: for a hardlink cluster upstream transfers the sorted-LAST member - the one match_gnums() flags FLAG_HLINK_LAST and finish_hard_link() completes - and links every other member (including the sorted-first) to it (hlink.c:113-194, hlink.c:496-565). oc's --write-batch shipped the cluster's single payload under the sorted-FIRST member's NDX, and the batch-replay receiver treated the sorted-first hlink_first member as the materialized data-holder. oc-self replay agreed with itself, so the divergence surfaced only across implementations. The live wire path is unaffected because oc's generator makes hlink_first the transferred member; only a recorded batch stream can place the data-holder on a different member. Three aligned changes: - Writer (engine local_copy batch): ship the cluster payload under the sorted-LAST member's NDX, matching upstream's FLAG_HLINK_LAST data-holder, so upstream can replay an oc batch. - Receiver replay commit (transfer receiver/transfer/replay.rs): record the just-committed hardlink member as its group's data-holder in the HardlinkApplyTracker. Which member the batch transferred is stream-dictated (now the sorted-last member), so the source cannot be inferred from disk presence - a stale pre-existing sorted-first member would otherwise win and the fresh payload be discarded. - Receiver create_hardlinks(): during batch replay only (self.local_replay), let every hlink member - including the sorted-first leader - resolve its group source through promote_hardlink_leader() (which returns the recorded data-holder) and the self-link guard, so an absent or stale sorted-first member is re-linked to the fresh data-holder. The live path is unchanged: there an absent hlink_first member means its own transfer was skipped/errored (FLAG_SKIP_HLINK) and must not be resurrected, so that path keeps skipping every hlink_first member. This keeps the network -H receiver and its skip/virtual-first semantics untouched. Un-ignores cross_impl_hardlink_batch_{pair,triple}_parity (added earlier as a registered known divergence); they now pass both directions for 2- and 3-member clusters. Fixes the UTS batch-only-remove-source-regression cell (replay into a pre-existing destination whose stale cluster members must be re-linked to the freshly transferred payload). oc-self #7956/#7928 stay green (they assert end state, which survives the data-holder change). upstream: hlink.c:113-194 match_gnums(), hlink.c:496-565 finish_hard_link().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an oracle-free integration test that pins the batch hardlink data-loss fix from #7928 ("ship hardlink payload under the sorted-first cluster NDX") so it cannot silently regress.
The gap this closes
The only existing hardlink-batch coverage,
replay_hardlink_pair_parityintests/batch_replay_upstream_parity.rs, is built onParityHarness, which returns early (a vacuous pass) whenever no upstream rsync oracle is discoverable (OC_RSYNC_UPSTREAM_RSYNCunset and notarget/interop/upstream-install/). On any build without an installed oracle there is therefore no guard against the hardlink-batch regression at all. The batch crate's replay unit tests have zero hardlink coverage.This new test drives oc's own
--write-batchthen--read-batch -aH, with no upstream dependency, so it always runs its assertions (0 skipped).Why it must exercise the exact bug (not a trivial case)
A local
--write-batchbuilds the flist/delta stream in traversal order, then remaps each delta NDX to the sorted position the replaying receiver assigns afterflist_sort_and_clean(). The engine'sreorder_hardlink_group_holderspromotes the name-sorted-last fresh cohort member to the data-holder, so it records the single payload, while the replaying receiver flags the name-sorted-first member as the cluster leader and expects the payload under its NDX (upstreamhlink.c:113-194 match_gnums()). Before #7928 the payload shipped under the holder's own sorted NDX, so the real leader got no data, was never written, and the other member was left unlinked - the cluster replayed as a single or missing file at exit 0.The cohort names are chosen so the sorted-first member (
aaa_leader.txt) is not the data-holder (zzz_holder.txt), which is precisely the case #7928 fixes. A single-name cohort, or one whose first and last names coincide, would pass against the pre-fix code and prove nothing.Placement
The fix lives on the write path in
crates/engine, which thebatchcrate cannot reach (it has noenginedependency). The regression can therefore only be pinned by a full write -> read round-trip, so this is a binary-level integration test rather than acrates/batchunit test.Mutation proof (non-vacuity)
Reverting the one-line emit-NDX remap in
crates/engine/src/local_copy/context_impl/options/batch.rs(ship under the holder's own sorted NDX instead of the sorted-first cluster leader's) and rebuilding makes the test go RED:Restoring the fix returns it to GREEN (
1 test run: 1 passed, 0 skipped). The empty stderr and success exit in the red arm reproduce the silent-data-loss signature the fix addresses.Test plan
cargo nextest run --test batch_hardlink_replay_regression- passes (0 skipped).cargo nextest run -p batch --all-features- green.cargo fmt --all -- --check,tools/ci/check_rustfmt_all.py,cargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings- clean.