Skip to content

pool, store: hold a template's record lock only for the re-promote commit - #430

Merged
CMGS merged 2 commits into
mainfrom
fix/promote-lock
Nov 3, 2026
Merged

CMGS merged 2 commits into
mainfrom
fix/promote-lock

Conversation

@CMGS

@CMGS CMGS commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

A re-promote held the template's record write lock across the whole publish: hashing every byte of the export, and on S3 uploading the changed chunks, up to the 30-minute transfer budget. Every claim served from that promoted template waited on the read lock for all of it, and that wait does not observe the claim's context, so goroutines stayed parked after clients left. Store generations already let a clone of the previous generation run beside a publish, so the lock only has to cover the pointer switch.

PublishDigested becomes PrepareDigested, which runs a publish up to the step that makes the generation current and returns that step as a commit function:

  • dir: prepare hashes the export; commit renames the generation in and writes meta.json.
  • s3: prepare scans, uploads chunks and writes the manifest; commit puts meta.json and removes staging. Plain Publish is prepare then commit, so checkpoints behave as before.
  • commitTemplate prepares with no lock held, then takes the record lock, re-checks the owner, commits and clears the labels.

Two promotes of one template still serialize at the commit and the later commit wins, as before; "later" is now the order their prepares finish. Claims stall at most for the commit, not the publish.

Tests: a claim with a 100 ms context during a re-promote blocked in prepare returns within its context (fails with the lock moved back above prepare); the store contract requires a prepared record to stay invisible until its commit on both backends. Prod +40 -34. Stacked on #420.

CMGS added 2 commits November 3, 2026 16:21
commitTemplate held lockRec across PublishDigested, which hashes the whole export and on S3 uploads every changed chunk, up to the 30 min budget. resolveGolden's rlockRec cannot be cancelled, so every claim of that template waited for the whole publish and stayed parked after its client left. The store now splits a digested publish into PrepareDigested (hash, upload chunks and manifest; nothing visible changes) and the commit it returns (the meta.json pointer). The owner re-check and the commit run under the lock; the rest runs outside it. Two promotes of one template still serialize at the commit, and the later commit wins as before.
@CMGS
CMGS force-pushed the fix/promote-lock branch from 5073269 to 71db84e Compare November 3, 2026 08:22
@CMGS
CMGS changed the base branch from review/post-417 to main November 3, 2026 08:22
@CMGS
CMGS merged commit 839ca5b into main Nov 3, 2026
2 checks passed
@CMGS
CMGS deleted the fix/promote-lock branch November 3, 2026 09:45
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