Skip to content

matchmakingserver: run a backfill pass when a player leaves a battleground - #98

Open
3kynox wants to merge 2 commits into
walkline:masterfrom
3kynox:fix/matchmaking-backfill-on-leave
Open

3kynox wants to merge 2 commits into
walkline:masterfrom
3kynox:fix/matchmaking-backfill-on-leave

Conversation

@3kynox

@3kynox 3kynox commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

A freed slot was only filled on the next enqueue into the same queue: a player already waiting could never enter a running battleground that lost a member, and the match stayed short-handed until someone new queued.

This kicks the regular queue pass (backfill first, then creation) right after the slot is freed, so the replacement is invited immediately. Verified live on my cluster: a leaver's seat is re-offered within a second and the joiner lands in the running match.

…round

A freed slot was only filled on the next enqueue into the same queue:
a player waiting in queue could never enter a running battleground that
lost a member. Kick the queue pass (backfill, then creation) right
after the slot is freed.
Copilot AI lite review requested due to automatic review settings August 30, 2026 13:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new async backfill trigger can overlap concurrent queue process runs and cause duplicate invites/links without a per-queue serialization/coalescing mechanism.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR improves battleground backfilling by triggering a queue processing pass immediately after a player leaves an active battleground, so an already-waiting group can be invited right away instead of waiting for the next enqueue.

Changes:

  • Added ProcessBackfill(ctx) to the PVPQueue interface and implemented it for GenericBattlegroundQueue and BattlegroundRandomQueue.
  • Updated PlayerLeftBattleground to trigger an async backfill pass for the affected queue/bracket after removing the player.
File summaries
File Description
apps/matchmakingserver/service/battleground-random-queue.go Exposes ProcessBackfill on the random-queue wrapper by delegating to the underlying generic queue.
apps/matchmakingserver/service/battleground-queue.go Extends PVPQueue with ProcessBackfill and routes it to the existing process logic.
apps/matchmakingserver/service/battleground_service.go Triggers a queue backfill pass after PlayerLeftBattleground updates the battleground state.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +152 to +154
func (q *GenericBattlegroundQueue) ProcessBackfill(ctx context.Context) error {
return q.process(ctx)
}
Comment on lines +656 to +661
go func() {
if err := queue.ProcessBackfill(context.Background()); err != nil {
log.Err(err).Msg("backfill pass after player left battleground failed")
}
}()
}
…fill pass

Review follow-ups: group selection in process() happens under a read
lock and removal only after the invite, so two overlapping runs
(concurrent enqueues, or the new leave-triggered backfill racing an
enqueue) could invite the same queued group twice - a dedicated mutex
now serializes process() runs. The backfill goroutine also gets a 10s
deadline so a stalled pass can't accumulate hung goroutines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants