mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-10 16:04:04 +00:00
fix(multiplayer): propagate allocated playlist
This commit is contained in:
@@ -30,7 +30,7 @@ UPDATE matches m
|
||||
SET allocation_id = 'allocation-' || candidate.match_id, allocation_claimed_at = $2
|
||||
FROM candidate
|
||||
WHERE m.match_id = candidate.match_id
|
||||
RETURNING m.match_id, m.region, m.protocol_version, m.allocation_id`
|
||||
RETURNING m.match_id, m.playlist, m.region, m.protocol_version, m.allocation_id`
|
||||
|
||||
const AllocatingMatchBuildSQL = `SELECT client_build
|
||||
FROM queue_tickets q
|
||||
@@ -200,10 +200,10 @@ func ClaimAllocatingMatch(ctx context.Context, db *sql.DB, transport string, now
|
||||
var item PendingAllocation
|
||||
found := false
|
||||
err := RunSerializable(ctx, db, DefaultSerializableAttempts, func(ctx context.Context, tx *sql.Tx) error {
|
||||
var matchID, region string
|
||||
var matchID, playlist, region string
|
||||
var protocol int
|
||||
var claimedID string
|
||||
err := tx.QueryRowContext(ctx, ClaimAllocatingMatchSQL, now.Add(-AllocationClaimLease), now).Scan(&matchID, ®ion, &protocol, &claimedID)
|
||||
err := tx.QueryRowContext(ctx, ClaimAllocatingMatchSQL, now.Add(-AllocationClaimLease), now).Scan(&matchID, &playlist, ®ion, &protocol, &claimedID)
|
||||
if err == sql.ErrNoRows {
|
||||
return nil
|
||||
}
|
||||
@@ -233,7 +233,7 @@ func ClaimAllocatingMatch(ctx context.Context, db *sql.DB, transport string, now
|
||||
if build == "" {
|
||||
return fmt.Errorf("allocating match has no participants")
|
||||
}
|
||||
item.Request = domain.AllocationRequest{AllocationID: claimedID, MatchID: matchID, Region: region, Build: build, Protocol: protocol, Transport: transport}
|
||||
item.Request = domain.AllocationRequest{AllocationID: claimedID, MatchID: matchID, Playlist: domain.Playlist(playlist), Region: region, Build: build, Protocol: protocol, Transport: transport}
|
||||
found = true
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
func TestAllocationMatchClaimSQLFencesConcurrentWorkers(t *testing.T) {
|
||||
checks := map[string][]string{
|
||||
ClaimAllocatingMatchSQL: {"FOR UPDATE SKIP LOCKED", "allocation_id = 'allocation-' || candidate.match_id", "allocation_claimed_at <= $1", "ORDER BY created_at, match_id"},
|
||||
ClaimAllocatingMatchSQL: {"FOR UPDATE SKIP LOCKED", "allocation_id = 'allocation-' || candidate.match_id", "allocation_claimed_at <= $1", "ORDER BY created_at, match_id", "m.playlist"},
|
||||
AllocatingMatchBuildSQL: {"match_participants", "queue_tickets", "ORDER BY q.client_build"},
|
||||
BindAllocatedMatchParticipantsSQL: {"allocation_id = $2", "server_id IS NULL", "SET server_id = $3", "FROM allocations", "state = 'ALLOCATING'", "revision = revision + 1"},
|
||||
ReleaseAllocatedMatchClaimSQL: {"allocation_id = $2", "allocation_id = NULL", "allocation_claimed_at = NULL"},
|
||||
|
||||
Reference in New Issue
Block a user