Skip to main content

max / makenotwork

503 B · 10 lines History Blame Raw
1 -- At most one running build globally. Enforces what
2 -- `claim_pending_build`'s NOT EXISTS subquery checks at app level — without
3 -- this index, two replicas racing through the claim path can each pass the
4 -- check and end up with two concurrent running builds. The losing INSERT/
5 -- UPDATE surfaces as a 23505 unique violation; `claim_pending_build` swallows
6 -- it and returns None.
7 CREATE UNIQUE INDEX ota_builds_single_running
8 ON ota_builds ((status = 'running'))
9 WHERE status = 'running';
10