feat(multiplayer): lease allocating match claims

This commit is contained in:
Josh Creek
2026-09-01 10:36:13 +01:00
parent 03ff8e485e
commit 6f7d61eafb
6 changed files with 248 additions and 5 deletions
@@ -0,0 +1,12 @@
-- 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;