Skip to content

ci: concentrate the sccache GHA write quota on one writer (upstream 429 drops 45-90% of writes) #901

Closed

Description

@athvin

The write errors in #893 are HTTP 429, and they are an upstream sccache bug

#893's first run showed Cache write errors 445 in test shard (rest) (equal to
its miss count — it stored nothing it compiled) and 316 of 742 in
fmt + clippy + docs, with Cache read errors: 0 and no error text logged.

Cause confirmed, not inferred: mozilla/sccache#2821
— ghac: cache writes are dropped on HTTP 429 because GHACache::build installs no RetryLayer.
The three facts that make it ours:

  • GitHub's Actions cache service rate limits per workflow run, shared across
    every job in it
    , and answers a burst of writes with HTTP 429 plus a
    retry-after of 1–21s.
  • sccache's GHACache::build installs logging but no RetryLayer, so
    opendal marks the error temporary and nothing acts on it. The write is dropped
    and the counter incremented.
  • Affected in 0.17.0 and "unchanged on main as of 2026-08-23", so the
    pinned 0.19.0 is affected. Upstream measured 45–90% write loss, which
    brackets our 43% and 100% exactly.

There is no env-var workaround for the throttling itself — the issue says so
explicitly, and SCCACHE_GHA_RW_MODE only disables writing outright.

What is and is not at risk

The cost saving is already banked and is not at risk. S3 egress is gone
whatever the hit rate does — that was $209/month of
DataTransfer-Out-Bytes, and this bug cannot bring it back.

What is at risk is the hit rate, which is the reason to run sccache at all.
A 12-job matrix drawing on one shared per-run quota means main stores only a
fraction of what it compiles per run. It will accumulate across runs, but each
run re-pays for what the previous one dropped, and the ledger's 95% target may
not arrive.

Fix: concentrate the per-run quota on one writer

The quota is per run, so the lever is fewer concurrent writers inside the
main run — the single-writer pattern rust.yml already states for
shared-key: rust and #889 just applied to the frontend caches.

# rust.yml top-level env — everything reads
SCCACHE_GHA_RW_MODE: READ_ONLY
# on the `lint` job only, overriding it
SCCACHE_GHA_RW_MODE: ${{ github.ref == 'refs/heads/main' && 'READ_WRITE' || 'READ_ONLY' }}

lint is the right writer: cargo clippy --workspace --all-targets plus
cargo doc --workspace compiles essentially the whole tree, and it is already
the designated single writer of the rust-cache key for the same reason.

This also closes the second risk recorded on #893 — PR runs stop writing
their own ~1.48 GB scope, which at 309 distinct PR branches in 7 days was
~457 GB of demand against a 20 GB limit. It restores exactly the S3 read-role
semantics (main writes, PRs read) without any IAM.

Verify

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions