-- 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;