mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 17:03:43 +00:00
feat(multiplayer): lease allocating match claims
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user