Repository navigation
fix(flaky): ubi-runner pack reads the live index with cat, not cp - #1
Draft
vorflux[bot] wants to merge 3 commits into
Draft
vorflux[bot] wants to merge 3 commits into
vorflux[bot] wants to merge 3 commits into
Conversation
pack copied the checkout's .git/index with cp while other git processes
may rewrite it. git replaces the index through a lockfile rename, and GNU
cp 9 exits 1 when its source is replaced mid-copy ("skipping file ...,
as it was replaced while being copied"). Under set -e that failed the
pack, and it flaked the free test "pack snapshots a plain checkout
without reading its live .git" (flaky-pass on main, 2026-10-30, shard 4).
cat keeps reading the inode it opened, so a rename beside it still
yields one whole index (the old or the new one). A missing index still
fails the pack with exit 1 and names .git/index.
…t/open race Opus review: cp never copied a torn index; it refused a whole one whose inode changed between its stat and open. Reword the comment to say so, and route a failed copy through die like the neighbouring pack steps.
…ks every snapshot --force-write-index makes each churn pass rename a new index over the live one, the race GNU cp refused. Packs 1 and 2 are now extracted and read with ls-files and status, and the missing-index case pins the pack: prefix.
Author
|
Drift check against upstream I did this check on a local scratch branch. I pushed nothing and did not change this PR branch (head
I have not rebased this PR. A human must decide on the rebase. |
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.
ubi-runner pack no longer fails when git rewrites the index during the copy
ubi-runner packbuilds the checkout tarball that a Ubicloud VM unpacks. It copied the live git index withcp. When another git process replaced the index at the wrong moment,cpexited 1 and the whole pack failed. This PR reads the index withcatinstead.Why —
cprefuses an index that git replaces mid-copyindex.lock, then renames it overindex.cp(9.4 here) stats the source path, then opens it, then compares the two.cpprintsskipping file ..., as it was replaced while being copiedand exits 1.set -euo pipefail, so the pack fails.cpnever copies a torn index. It refuses a whole, valid new one.What — the index copy reads one file, once
catopens the index path once and reads that inode to the end. A rename after the open does not affect the read, and a rename before the open gives the complete new index.pack: could not copy the index of <src>, in the same style as the other pack errors.How — pack flow
--- config: flowchart: wrappingWidth: 1000 --- flowchart TD A["Fetch refs into<br/>a fresh repo"] --> B["Replay remote.*<br/>and branch.* config"] B --> C["Read live index<br/>with cat (was cp)"] C --> D["Pack staged blobs<br/>HEAD does not have"] D --> E["tar working tree<br/>plus snapshot .git"] G["git elsewhere renames<br/>index.lock over index"] -. "race" .-> Ccatreads the live index once. A concurrent rename cannot make it fail..git.In one line: a concurrent git write can no longer make
packfail on the index copy.Evidence: failure rate before and after
All runs use the real
ubi-runner.sh packagainst the test's own fixture repository, with git writers that replace the index during each pack. "Before" is thecpversion; "after" is this branch. Both variants ran the same number of packs on the same machine (16 cores, git 2.43.0, coreutils 9.4).cprefused the indexcp/index failures--index-versiontogglersupdate-index --force-write-indexloopsskipping file ..., as it was replaced while being copied.fatal: git upload-pack: not our ref 0000…from the ref fetch, when a ref is deleted mid-fetch. That failure exists on fork main and is not in this PR's scope. 3 vs. 5 is within noise for that rate.cpand withcatboth passed 40/40. The flake rate is too low to see at n=40 at the test level, so the stress harness above is the measurement.Testing
bun test test/ubicloud-runner.test.tsexpect()calls, 61.1smain+ this patchmainat 5532345expect()calls, 62.9sbun testspawnsync-timeout-tripwire, egress-receipt-wiring, bun-entry-isolation, script-invocation-tripwirebash -n scripts/ubicloud/ubi-runner.shbun run test(17 shards)test/ubicloud-runner.test.tspassed in it.The full free suite is red. This PR is not release-accepted. What I measured about the 79 failures:
browse/,make-pdf/, and design-lint tests that launch Chromium. Logs showChromium sandboxing failed!and daemon readiness timeouts in this Linux sandbox.ubi-runnerorubicloud.main(ce3a093): 361 pass, 75 fail. The two runs share 58 failing test names. 5 fail only on forkmain, and 5 fail only on the branch.test/bootstrap-retention-shard.test.ts,test/cso-cli.test.ts,browse/test/xvfb.test.ts,test/autoplan-driver.test.ts) pass alone on the branch: 79 pass, 0 fail. They failed under 16-shard load.Upstream overlap (garrytan/gstack)
mainis 11 commits ahead of forkmain. v1.91.341.0 fix(ubicloud): no zombie VMs: owner required, 3h TTL, legacy sweep, leftover line (GST-118) garrytan/gstack#3652 is already merged there as 5532345 (v1.91.341.0).scripts/ubicloud/ubi-runner.shandtest/ubicloud-runner.test.ts, but not the same lines. Its runner hunks do not touch thecmd_packindex copy, and upstream still usescpthere.main(runner offset +35 lines, test offset +28 lines). The focused test file passes there (34/34, above).Review
Separate review by Claude Opus 5.5 (
claude-opus-5-5, direct API call; the reviewer did not write the change). Verdict: APPROVE WITH NITS. Risk: 2/10.Addressed in 290ecc0 and 2040565:
cpcould copy a torn index. Reworded:cprefuses a whole new index;catreads the file it opened.|| die "pack: could not copy the index of $src"added, so a failed copy names itself.--force-write-index, so every pass renames a new index over the live one.git ls-files -sandgit status --shorton each, so "no broken index" is an assertion.pack: could not copy the index ofmessage.Not done:
cp." Correct; the regression check is only meaningful with GNU coreutils. Not changed.Risk Assessment
cat ... > filecreates the copy with the umask mode instead of the source mode. For a normal 0644 index the result is the same. Undercore.sharedRepositorythe tarball gets 0644 instead of 0664; the VM does not depend on that mode.Out-of-Scope Feedback
Session Details
(aside)to your comment to have me ignore it.