Skip to content

Write the manifest object before the tag and the referrer link - #2

Merged
EricAndrechek merged 1 commit into
mainfrom
fix/referrer-link-after-manifest
Oct 7, 2026
Merged

EricAndrechek merged 1 commit into
mainfrom
fix/referrer-link-after-manifest

Conversation

@EricAndrechek

Copy link
Copy Markdown
Member

Problem. For a manifest pushed by digest or by a mutable tag, putManifestInner wrote the manifest-by-digest object, the tag and the referrer link (<repo>/_referrers/<subject>/<digest>) concurrently. If storage refused the manifest write (for example, a transient R2 error) while the link or tag write succeeded, the link or tag named a manifest that doesn't exist. A client that follows referrer links then waits indefinitely for the missing manifest.

Fix. Await the manifest-by-digest write first. The tag and referrer-link writes start only after it has succeeded. If the manifest write fails, nothing that names it is written, and a retried PUT (every write here is write-once) completes all three. The immutable-tag branch already ordered its writes this way and is unchanged.

Tests (test/r2-write-order.test.ts), for each push style (mutable tag, immutable tag, by digest):

  • A referrer PUT whose manifest write throws rejects and leaves no referrer link and no tag. Retrying it succeeds and writes the manifest, the link and the tag.
  • A successful referrer PUT writes exactly the manifest, the link and (if any) the tag.
  • The previous test asserting that the tag and digest writes start concurrently is replaced by one asserting that the digest write finishes first.
  • With the concurrent write restored, the failed-manifest tests fail for the mutable-tag and by-digest styles.

The suite goes from 125 to 131 tests; typecheck, eslint and prettier are clean.

In the non-immutable-tag path the manifest-by-digest write ran in parallel
with the tag and referrer link writes. If the manifest write failed while
the link write succeeded, the link pointed at a manifest that was never
stored, and a client following referrer links waited for it indefinitely.
Await the digest write first; a failed write now leaves no link and no tag.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@EricAndrechek
EricAndrechek merged commit 98b01fd into main Oct 7, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant