Repository navigation
ci(playwright): break the cache-eviction death spiral + make apt retries survivable - #31746
Merged
Merged
Conversation
…ies survivable Diagnosis of runs 32223093113 and 32233411840 exposed three compounding defects that no amount of per-symptom patching was going to fix: 1. CACHE-EVICTION DEATH SPIRAL. The repo cache store measured 17.5 GB against a 10 GB LRU budget, with 49 of 50 caches on ephemeral refs (merge-queue branches, PR merge refs). The explicit yarn cache from #31730 was the biggest single source — on an ephemeral ref the exact key can never pre-exist, so every job saved a fresh ~700 MB duplicate (9 copies = 6.4 GB observed) even when restore-keys had restored content perfectly. Those saves evicted every main-scoped cache within ~30 minutes of creation (the #31718 apt cache created 06:15 was gone before 06:49), which turned downstream "cache hits" into cold fetches against apt mirrors / registry.yarnpkg.com / the Playwright CDN — and a bad day on any of those took the whole matrix down. More misses meant more ephemeral saves, feeding back into more eviction. Fix: every yarn and browser cache step in the reusable workflow is now RESTORE-ONLY (actions/cache/restore@v5) — ephemeral refs never save. The one writer is populate-playwright-apt-cache.yml, which runs on main and now warms all three caches (yarn, browser, apt), on the 6 h schedule, on dispatch, and on pushes to main touching yarn.lock / .nvmrc / the workflows. The plan job's run-scoped browser seeder is deliberately kept save-capable for lockfile-change entries; once eviction stops it no-ops on hit. Projected steady state ~6-8 GB, under budget, no evictions. 2. USELESS INSTALL RETRY. `timeout --signal=TERM ... npx playwright install-deps` only signals the direct child; the underlying apt-get survives and keeps holding /var/lib/apt/lists/lock. Run 32233411840 showed the exact sequence: apt had failed over from the dead Azure mirror to archive.ubuntu.com and was slowly succeeding, the 8-minute ceiling killed the wrapper mid-download, and the retry then died instantly on "Could not get lock ... held by process 15226". The same stale lock can be left by a timed-out cache-apt-pkgs action earlier in the job. Fix: a reap_apt() helper (killall -9 apt/apt-get/dpkg, remove stale lock files, dpkg --configure -a) runs BEFORE the first attempt and between attempts at both install-deps call sites. The shard job's single-attempt install gains the same one-retry loop the fixture builder already had. This adopts the diagnosis from PR #31737 at the location where it can actually work — the stale lock is created by our own timed-out first attempt, so clearing locks before the cache action (as #31737 does) runs too early to help. 3. POPULATE WORKFLOW TOO NARROW. It only warmed the apt cache; the yarn and browser caches had no main-scoped writer at all, so their first miss on any ephemeral ref started the duplicate-save churn. Verified: YAML valid on both files; all 6 yarn/browser cache steps in the reusable workflow audited restore-only; the reap+retry idiom tested under bash -e; the plan-job seeder confirmed retained. Co-Authored-By: Claude Fable 5 <[email protected]>
chirag-madlani
requested review from
ShaileshParmar11 and
karanh37
as code owners
August 19, 2026 09:26
Contributor
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
The populate job ran its warmers sequentially with fail-fast semantics: a yarn-registry outage surviving all three retries (or a Chromium CDN failure) killed the job BEFORE the apt writer ran — blocking the refresh of the one cache whose absence takes down whole matrices, which is exactly the failure this workflow exists to prevent. Restructured: * apt populate runs FIRST (no node/yarn dependency) and continue-on-error, so nothing can starve it and its own failure cannot starve the others. * yarn and browser warmers are continue-on-error with explicit restore/save pairs; each save is gated on its warmer SUCCEEDING. The gating also fixes a latent bug a bare continue-on-error would have introduced: actions/cache's post-job save runs when the job succeeds, so a failed yarn install would have permanently baked a partial ~/.cache/yarn under the exact lockfile key (actions/cache never overwrites an existing key). * the browser warmer is additionally gated on the yarn warmer succeeding — npx resolves the pinned @playwright/test from the local install. * a final "Report warm failures" step fails the job if ANY warmer failed — full signal on schedule/dispatch, but only after every cache had its chance to refresh. Verified: YAML valid; apt package list + version still byte-identical to both reusable-workflow call sites; yarn/browser keys match the restore-only steps. Co-Authored-By: Claude Fable 5 <[email protected]>
Code Review ✅ ApprovedConverts ephemeral Playwright yarn and browser caches to restore-only mode while adding orphaned apt-process cleanup and retry logic. No issues found. OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
This branch was previously deployed
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.
Summary
Root-cause fix for the recurring setup failures (runs 32223093113, 32233411840). Supersedes #31737 — its apt-lock diagnosis was half right, and its logic is adopted here at the location where it can actually work.
Defect 1 — cache-eviction death spiral (the systemic wall)
Measured state: 17.5 GB of caches against the 10 GB LRU budget, 49 of 50 on ephemeral refs.
actions/cachesaved a fresh duplicate per job. The ci(playwright): survive registry 5xx — yarn restore-keys fallback + retry #31730 yarn cache alone: 9 × ~700 MB = 6.4 GB of churn.Fix: all yarn + browser cache steps in the reusable workflow become restore-only (
actions/cache/restore@v5). The single writer ispopulate-playwright-apt-cache.yml(now "Populate Playwright CI caches"), which warms yarn + browser + apt from main's scope — on the 6 h schedule, on dispatch, and on pushes touchingyarn.lock/.nvmrc/ the workflows. The plan job's run-scoped browser seeder stays save-capable for lockfile-change entries (no-ops on hit once eviction stops). Projected steady state: ~6–8 GB, under budget, zero evictions.Defect 2 — the install retry could never succeed
Run 32233411840's exact sequence:
archive.ubuntu.com(Ign:→Hit:) and was slowly succeedingtimeoutkilled thenpxwrapper mid-download —timeoutonly signals the direct child; the underlyingapt-get(pid 15226) survived, still holding/var/lib/apt/lists/lockE: Could not get lock … held by process 15226→ exit 100 → job deadFix: a
reap_apt()helper (kill orphaned apt/dpkg, remove stale locks,dpkg --configure -a) runs before the first attempt and between attempts at bothinstall-depscall sites. The shard job also gains the one-retry loop it never had. This is #31737's cleanup at the right place — the stale lock is created by our own timed-out first attempt (or a timed-out cache action in the same job), so clearing locks before the cache step runs too early to help.Defect 3 — populate workflow too narrow
It only warmed apt; yarn and browser caches had no main-scoped writer at all, so their first ephemeral-ref miss started the duplicate churn. Now it warms all three.
Verified
bash -e.populate-playwright-apt-cache.ymlonce, thengh api /repos/{owner}/{repo}/actions/cache/usageshould trend below 10 GB within a few hours and?key=cache-apt-pkgs/?key=yarn-pkg-cacheshould show stableref=refs/heads/mainentries.Recommendation for #31737
Close in favor of this PR — the lock-clearing idea is incorporated where it's effective (inside the retry loop, after our own timeout creates the lock).
Related: #31718, #31730, #31691, #30847.
🤖 Generated with Claude Code
Greptile Summary
The PR makes Playwright cache consumption restore-only on ephemeral refs, centralizes main-scoped apt, yarn, and browser cache writes, and adds apt-process cleanup around retried browser dependency installation.
Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Populate workflow on main] --> B[Warm apt cache first] B --> C[Warm yarn cache] C --> D[Warm browser cache] B --> E[Main-scoped apt cache] C --> F[Main-scoped yarn cache] D --> G[Main-scoped browser cache] E --> H[Reusable Playwright jobs restore only] F --> H G --> H H --> I[Reap stale apt processes on cache miss] I --> J[Retry install-deps]Reviews (2): Last reviewed commit: "address greptile P1 — make the cache war..." | Re-trigger Greptile