Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Overlay-base cache restore misses on cache backends that only prefix-match restoreKeys

Offen Anfängerfreundlich
#4,202 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
1/5
Geschätzter Aufwand
Unter einer Stunde
Anfängerfreundlichkeit
90/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
typescript
Bereich
ci-cd

Rechercherichtung

Beginne in src/overlay/caching.ts ungefähr bei den Zeilen 290–302, wo downloadOverlayBaseDatabaseFromCache actionsCache.restoreCache aufruft und dabei das Schlüsselpräfix als einziges Argument übergibt; vergleiche das mit dem Upload-Pfad direkt darüber, der codeql-overlay-base-database-<hash>-<sha>-<run_id> schreibt. Die Korrektur besteht darin, dasselbe Präfix als drittes Argument (restoreKeys) zu übergeben. Führe dann die vorhandenen Overlay-Caching-Tests in der TypeScript-Suite aus, um zu bestätigen, dass sich das aktuelle GitHub-Cache-Verhalten nicht verschlechtert. Fertig ist die Änderung, wenn PR-Runs auf Backends, die nur Präfixe unterstützen, den Cache wiederherstellen können und sich das Verhalten auf GitHub-gehosteten Runnern nicht ändert.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Summary

downloadOverlayBaseDatabaseFromCache restores the overlay-base database by passing the key prefix as the primary key, with no restoreKeys:

https://github.com/github/codeql-action/blob/d208ec71e39ae46397cbf6569bef8439b9aab974/src/overlay/caching.ts#L290-L302

actionsCache.restoreCache(
  [dbLocation],
  cacheRestoreKeyPrefix,
  undefined,
  { segmentTimeoutInMs: 3000 },
)

This depends on the primary key matching by prefix. GitHub's cache service does that, but some Actions-cache-compatible backends only prefix-match restoreKeys. One example is the transparent cache on Blacksmith runners. On those backends, PR runs can never restore the overlay-base database, even though default-branch runs upload it successfully. Every PR run then falls back to a full analysis.

What we see

Default-branch run, on the same runner type:

Setting overlay database mode to overlay-base with caching because we are analyzing the default branch.
Uploading overlay-base database to Actions cache with key codeql-overlay-base-database-1-<hash>-python-2.27.1-<sha>-<run_id>-1
Successfully uploaded overlay-base database from /home/runner/_work/_temp/codeql_databases

Pull request run:

Setting overlay database mode to overlay with caching because we are analyzing a pull request.
Looking in Actions cache for overlay-base database with restore key codeql-overlay-base-database-1-<hash>-python-2.27.1-
No overlay-base database found in Actions cache
No overlay-base database found in cache, reverting overlay database mode to none.
Minimal reproduction of the backend difference

A cache entry saved as probe-<run_id>-full, then restored in a later job on the same branch with actions/cache/restore@v4:

Restore GitHub-hosted runner Blacksmith runner
key: probe-<run_id>- (prefix as the primary key, like this action) hit miss
key: probe-<run_id>-nomatch, restore-keys: probe-<run_id>- hit hit
Suggested fix

Also pass the prefix as a restore key:

actionsCache.restoreCache(
  [dbLocation],
  cacheRestoreKeyPrefix,
  [cacheRestoreKeyPrefix],
  { segmentTimeoutInMs: 3000 },
)

On GitHub's cache this matches exactly the same entries as today, since the prefix is tried first either way. On backends that only prefix-match restore keys, overlay analysis starts working.

Environment
  • github/codeql-action/init and analyze @v4, CodeQL bundle 2.27.1
  • build-mode: none, languages python and javascript-typescript
  • Third-party hosted runners (Blacksmith) whose actions/cache calls go to their own cache backend
Vorherrschende Sprache
TypeScript
Sterne
1.7k
Forks
494
Ø Merge
1 T. 10 Std.
Gemergte PRs (30 T.)
52

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus github/codeql-action

Alle Issues in github/codeql-action

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.