Skip to content

ci(playwright): break the cache-eviction death spiral + make apt retries survivable - #31746

Merged
chirag-madlani merged 2 commits into
mainfrom
ci/cache-churn-and-retry-fix
Aug 19, 2026
Merged

chirag-madlani merged 2 commits into
mainfrom
ci/cache-churn-and-retry-fix

Conversation

@chirag-madlani

@chirag-madlani chirag-madlani commented Aug 19, 2026 •

Copy link
Copy Markdown
Collaborator

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.

Fix: all yarn + browser cache steps in the reusable workflow become restore-only (actions/cache/restore@v5). The single writer is populate-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 touching yarn.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:

  1. apt failed over from the dead Azure mirror to archive.ubuntu.com (Ign: → Hit:) and was slowly succeeding
  2. the 8-min timeout killed the npx wrapper mid-download —
  3. but timeout only signals the direct child; the underlying apt-get (pid 15226) survived, still holding /var/lib/apt/lists/lock
  4. the retry died instantly: E: Could not get lock … held by process 15226 → exit 100 → job dead

Fix: a reap_apt() helper (kill orphaned apt/dpkg, remove stale locks, dpkg --configure -a) runs before the first attempt and between attempts at both install-deps call 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

  • YAML valid on both files.
  • All 6 yarn/browser cache steps in the reusable workflow audited restore-only; plan-job seeder confirmed retained.
  • reap+retry idiom tested under bash -e.
  • After merge: dispatch populate-playwright-apt-cache.yml once, then gh api /repos/{owner}/{repo}/actions/cache/usage should trend below 10 GB within a few hours and ?key=cache-apt-pkgs / ?key=yarn-pkg-cache should show stable ref=refs/heads/main entries.
  • Merge-queue shards log cache hits and 1–5 s installs even during mirror incidents.

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.

  • Runs the apt cache population before the yarn and browser warmers so their failures cannot block apt refresh.
  • Gates cache saves on successful warmers and reports failures only after each independent cache has had an opportunity to update.
  • Reaps orphaned apt and dpkg processes before retrying timed-out Playwright dependency installation.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
.github/workflows/playwright-e2e-reusable.yml Converts ephemeral-ref yarn and browser caches to restore-only usage and adds apt cleanup plus retry handling at both dependency-install call sites.
.github/workflows/populate-playwright-apt-cache.yml Expands the main-scoped population workflow to warm apt first and then independently warm and save yarn and browser caches.

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]
Loading

Reviews (2): Last reviewed commit: "address greptile P1 — make the cache war..." | Re-trigger Greptile

…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]>
Copilot AI lite review requested due to automatic review settings August 19, 2026 09:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 skip-pr-checks label.

@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels Aug 19, 2026
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]>
Copilot AI review requested due to automatic review settings August 19, 2026 09:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chirag-madlani
chirag-madlani merged commit ee197ba into main Aug 19, 2026
72 of 73 checks passed
@chirag-madlani
chirag-madlani deleted the ci/cache-churn-and-retry-fix branch August 19, 2026 09:40
@gitar-bot

gitar-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Converts ephemeral Playwright yarn and browser caches to restore-only mode while adding orphaned apt-process cleanup and retry logic. No issues found.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants