Skip to content

[PR] fix: keep catalog invalidation effective across overlapping requests - #7020

Closed
Afloat16 wants to merge 2 commits into
ranxianglei:masterfrom
Afloat16:2026-11-17_catalog-invalidation-races
Closed

Afloat16 wants to merge 2 commits into
ranxianglei:masterfrom
Afloat16:2026-11-17_catalog-invalidation-races

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Problem

The Codex catalog wrapper captures an entry per request. A concurrent 401/403 can invalidate the shared cache while an older request still holds that entry. The older request can replay stale metadata or republish it after reading its body. A previously started atomic rename can also land after invalidation deleted the file, reviving the catalog across a factory restart.

Change

Associate each credential-scoped cache key with a bounded generation token and advance it on invalidation. Check that token before fallback, revalidation, writes, and invalidation so an old request cannot modify a later generation. Sequence only disk mutations for the same key, ensuring deletion follows any already-started rename. Network requests and unrelated credentials remain concurrent. Original upstream responses still reach their callers.

Validation

  • Base: 301e1a5459a77d5578206927c8062a58381af642.
  • Eight deterministic new tests: 7 failures / 1 pass on the base, 8 passes with the fix.
  • Coverage includes overlapping HTTP/network failures, deferred successful bodies, stale conditional 304, successful refresh after invalidation, stale denial, credential isolation, and a blocked rename against a real temporary disk directory. Restarting the factory verifies the deleted catalog stays unavailable.
  • Catalog cache, validator, and new race suites: 25 tests passed.
  • npm run typecheck, npm run build, and git diff --check: passed.
  • Synthetic metadata and credentials only; no live provider calls. The new coordination is process-local and does not claim cross-process locking.

Prior work

#3996 introduced the cache, #4864 rejected unconditional 304, and #6145 verifies conditional validators. Their behaviors and existing tests remain intact. Live issue/PR searches and author history were checked for the new concurrency defect.

Fixes #7019

Merge upstream master 6a641f3, including the architecture module-map and schedule-independent ranxianglei#2929 probe fixes.

Preserve the existing PR head and exact contribution patch. Validation of this refreshed head runs in upstream CI; no local test rerun is claimed.
@ranxianglei

Copy link
Copy Markdown
Owner

This fix is included verbatim (original commits and authorship preserved) in the merged batch PR #7074 — the changes are already on master. Closing to avoid a duplicate merge. 该修复已随批量 PR #7074 原样合入 master,为避免重复合并,关闭此 PR。

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Overlapping Codex catalog requests can revive metadata after authoritative invalidation

2 participants