Skip to content

ci: serialize local CI runs per checkout and fix load-only test flakes - #705

Merged
dmealing merged 6 commits into
mainfrom
fm/mo-ci-load-flakes
Dec 3, 2026
Merged

dmealing merged 6 commits into
mainfrom
fm/mo-ci-load-flakes

Conversation

@dmealing

@dmealing dmealing commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

What Changed

  • scripts/ci-local.sh now claims its checkout through a pid-and-start-time file in the worktree's git directory. A second run in the same checkout refuses and names the first. A stale claim from a killed run is replaced. A run started by the claimant inherits the claim through MO_CI_CLAIM_HOLDER. scripts/test-ci-checkout-claim.sh tests this and runs in the gates lane.
  • Rust codegen tests: generated_workspace holds an exclusive lock on the shared target directory for the life of the returned Workspace, so parallel workspaces take turns. copy_tree now reads and writes file bytes instead of using fs::copy. The per-test BUILD mutex in render_helper_conformance.rs is removed.
  • TypeScript test and integration fixes: the CLI eject depth test builds one compiler program for all owned copies instead of one per copy. The MySQL test container adds allowPublicKeyRetrieval=true to its URL and reports the last connect error on readiness timeout. CONTRIBUTING.md documents the one-run-per-checkout rule and the lock-removal step.

Intentional rider: MySQL integration tests on main

Not a load flake, but in this PR on purpose: main's ts-slow lane failed on every push from 2026-12-03 (5 local-ci runs checked, e.g. run 47084122616). The 1.3.1 lockfile regen moved mysql2 from 3.24.6 to 3.26.1, which refuses caching_sha2_password public-key retrieval over non-TLS, so every connection to the throwaway MySQL 8.4 container was refused and all 7 MySQL test files timed out at the 180s readiness deadline. It reproduced locally with no load. The container URL now carries allowPublicKeyRetrieval=true (a throwaway server on 127.0.0.1), and the readiness timeout reports the last connect error, which the server log alone had hidden.

Full-parallel local CI evidence

Before (2026-12-01): scripts/ci-local.sh running 8 lanes at once failed java-reactor (NoClassDefFoundError), conformance: rust (api_contract 404 on the approve route) and conformance: typescript (the eject-contract depth test over its 60s limit); each was green rerun alone. Cause for Java and Rust: two ci-local runs in one checkout rebuilding server/java and server/rust under each other. Cause for TypeScript: one compiler program per ejectable generator (98.8s -> 14.2s at load ~200 after the fix).

After, flagless scripts/ci-local.sh --strict-toolchains, 8 lanes at once on a 32-core machine at load average ~26:

Run Wall time Result
5 31m52s java-reactor, conformance: rust, conformance: typescript and every other lane green, except integration-tests (ts) (reaper-kill's nested ci-local was refused by the new checkout claim; fixed in this PR by MO_CI_CLAIM_HOLDER) and install size budget (stale dist/ in a reused worktree; a clean rebuild measured 36146236 bytes, identical to main)
6 20m05s java-reactor (9m17s), conformance: rust (6m57s), conformance: typescript (7m40s) and integration-tests (ts) green, the last including all 7 MySQL files. The C# lane and the showcase check failed in seconds on dangling obj/ links into a cleared RAM scratch directory (environment); rerun after restoring them: conformance: csharp, export surface (csharp), integration-tests (csharp) and the showcase check green

The 7 MySQL files alone, under mysql2 3.26.1 against real MySQL 8.4 containers: 410 pass, 0 fail. The review round's later changes (atomic stale-claim takeover, TZ-pinned start time, byte copies in the Rust test harness) landed after runs 5 and 6; the checkout-claim test covers the first two, and hosted CI covers the rest.

Validation took 2 no-mistakes runs: the first opened this PR, and the second pushed the merge of main after #704 conflicted in ci_cleanup.

Validation

Risk Assessment

✅ Low: The changes are confined to CI scripts, test harnesses and a docs paragraph, and tracing the claim takeover, nested-run, workspace-lock and shared compiler-program paths found no new material defect beyond items already decided in earlier rounds.

Testing

Drove the checkout-claim fix live through the real ci-local.sh in a throwaway repo; all 17 checks passed, covering refusal under a live claim, stale-claim takeover, the TZ-pinned start-time comparison, and claim release on exit. The Rust mtime/serialization, MySQL and java-reactor fixes were not driven live (heavy build or container outside budget), so the intent to fix those load-only lanes is not yet demonstrated. Evidence is the script output above; no artifact file written. Scratch dirs removed; worktree clean.

  • Live validation: ⚠️ inconclusive - 2 of 3 scenarios driven live against the product
Scenario Result Live Evidence
A second ci-local.sh run in the same checkout is refused while a live claim exists, and runs no lane (real script, throwaway repo, stand-in cargo) ✅ pass live scripts/test-ci-checkout-claim.sh part 2: 'ci-local.sh refuses while a live claim exists -> 2' and 'a refused ci-local.sh runs no lane -> no'
A claimed run releases the checkout claim on exit, and a stale or reused-pid claim is taken over (only one of two racing runs wins) ✅ pass live scripts/test-ci-checkout-claim.sh: 'a claim left by a run that is gone is replaced', 'two runs after one left-over claim: only one gets it', 'the claim file is gone after a claimed run exits'
Rust api_contract, MySQL throwaway container and java-reactor load-flake fixes hold under concurrent load ⏸️ untested no Tried to reason through a scoped run, but reproducing the mtime race needs a Rust workspace cargo build, MySQL needs a container, and java-reactor needs a Maven reactor under load. Each is outside the…
  • Outcome: ⚠️ 2 warnings across 1 run (8m36s)

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 2 warnings
  • ⚠️ Only the checkout-claim fix was driven live. The Rust api_contract mtime and serialization fix, the MySQL allowPublicKeyRetrieval change and the java-reactor NoClassDefFound fix were not driven, so the load-only flake intent is not yet demonstrated for those three lanes. Needs a cargo workspace build, a MySQL container and a Maven reactor run.
  • ⚠️ live validation verdict: inconclusive (2 of 3 scenarios were driven live against the product); untested: Rust api_contract, MySQL throwaway container and java-reactor load-flake fixes hold under concurrent load
  • Live validation: ⚠️ inconclusive - 2 of 3 scenarios driven live against the product
Scenario Result Live Evidence
A second ci-local.sh run in the same checkout is refused while a live claim exists, and runs no lane (real script, throwaway repo, stand-in cargo) ✅ pass live scripts/test-ci-checkout-claim.sh part 2: 'ci-local.sh refuses while a live claim exists -> 2' and 'a refused ci-local.sh runs no lane -> no'
A claimed run releases the checkout claim on exit, and a stale or reused-pid claim is taken over (only one of two racing runs wins) ✅ pass live scripts/test-ci-checkout-claim.sh: 'a claim left by a run that is gone is replaced', 'two runs after one left-over claim: only one gets it', 'the claim file is gone after a claimed run exits'
Rust api_contract, MySQL throwaway container and java-reactor load-flake fixes hold under concurrent load ⏸️ untested no Tried to reason through a scoped run, but reproducing the mtime race needs a Rust workspace cargo build, MySQL needs a container, and java-reactor needs a Maven reactor under load. Each is outside the…
  • scripts/ci-local.sh --affected --strict-toolchains
  • scripts/test-ci-checkout-claim.sh with DEV_SCRATCH set to a throwaway dir: runs the real scripts/ci-local.sh in a throwaway git repo with a stand-in cargo. Exit 0, all checks passed.
  • Covered: free checkout claimed; live claim refused; refusal leaves claim in place; live claim refused from another TZ; nested run inherits claim; stale claim replaced (pid reused or process gone); two runs after one stale claim, only one wins; ci-local.sh refused while live claim exists (exit 2) and runs no lane; claimed run reaches lane; second concurrent run refused; claim file removed after claimed run exits.
  • Baseline: configured scripts/ci-local.sh --affected --strict-toolchains passed at this target commit (not re-run).
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

java-reactor (NoClassDefFoundError) and the Rust api_contract corpus (404 on the
approve route) failed because two scripts/ci-local.sh runs shared one checkout:
one run's `mvn clean` deleted the classes the other's tests loaded, and cargo
treats a generated path crate at the same workspace-relative path as one build,
so one run's probe linked the other corpus's code. ci-local now claims the
checkout (a pid + start-time file in the worktree's git dir) and a second run
refuses, naming the first; scripts/test-ci-checkout-claim.sh pins it in gates.
The Rust test harness also holds an exclusive lock on the shared gen-check
target for each generated workspace's lifetime, so parallel tests in one binary
and concurrent cargo test processes cannot run each other's probes.

conformance: typescript failed on the eject-contract depth test's 60s limit: it
built one TypeScript program per ejectable generator. It now builds one program
for all owned copies and scans each copy through it (98.8s -> 14.2s at load ~200).
…3.26

The 1.3.1 lockfile regen moved mysql2 from 3.24.6 to 3.26.1, which no longer
fetches the server's RSA key for caching_sha2_password over a non-TLS
connection. MySQL 8.4 authenticates root that way, so every connection to the
test container was refused (PUBLIC_KEY_RETRIEVAL_NOT_ALLOWED) and all seven
MySQL files in ts-slow timed out at the 180s readiness deadline on every main
push since. The container URL now carries allowPublicKeyRetrieval=true, which
every consumer (bare URL or { uri }) picks up; the risk the default guards
against does not apply to a throwaway server on 127.0.0.1.

The readiness timeout now reports the last connect error: it printed only the
server log, which showed a ready server and hid the client-side refusal.
The integration suite's reaper-kill test starts `ci-local.sh --integration-only
--only python` from inside a full run so it can kill it. The one-run-per-checkout
claim refused that nested run, so its sidecar never started and the test failed
on every full run. The claiming run now exports its claim as MO_CI_CLAIM_HOLDER;
a run that inherited exactly the live claim runs without taking or releasing it.
A run started from anywhere else does not carry the variable and is still
refused. scripts/test-ci-checkout-claim.sh pins the export, the nested case and
the refusal of a run carrying some other claim.
@dmealing
dmealing merged commit ae2da72 into main Dec 3, 2026
11 checks passed
@dmealing
dmealing deleted the fm/mo-ci-load-flakes branch December 3, 2026 14:05
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