mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-10 16:04:04 +00:00
13 lines
602 B
SQL
13 lines
602 B
SQL
-- Allocation is an external call, so a durable leased claim fences competing
|
|
-- allocator replicas before any provider request. A timed-out claim can be
|
|
-- recovered with the same deterministic allocation ID after a worker crash.
|
|
ALTER TABLE matches
|
|
ADD COLUMN allocation_id TEXT UNIQUE,
|
|
ADD COLUMN allocation_claimed_at TIMESTAMPTZ,
|
|
ADD CONSTRAINT matches_allocation_claim_pair
|
|
CHECK ((allocation_id IS NULL) = (allocation_claimed_at IS NULL));
|
|
|
|
CREATE INDEX matches_allocating_claimable
|
|
ON matches (created_at, match_id)
|
|
WHERE state = 'ALLOCATING' AND server_id IS NULL;
|