Skip to content

matchmakingserver: never yank an active participant from the queue + trace backfill decisions - #100

Open
3kynox wants to merge 2 commits into
walkline:masterfrom
3kynox:fix/matchmaking-active-participant-guard
Open

3kynox wants to merge 2 commits into
walkline:masterfrom
3kynox:fix/matchmaking-active-participant-guard

Conversation

@3kynox

@3kynox 3kynox commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Two issues found while chasing an 11v10:

  • RemovePlayerFromQueue follows every battleground link of the queue type and removed seated participants from running matches. Guarded with IsActivePlayer: active players only leave through PlayerLeftBattleground, queue/invite links are still undone.
  • The service was blind exactly where that desync builds up: no trace for backfill invites, rejected join confirmations (the error was swallowed by a bare return), or invite expirations. Added the three log points, and the expiry path now unlinks only its own battleground.

Verified live: the traces made the 11v10 reproducible and the guard removes the yank; backfill decisions are now auditable per team (active/invited counts).

…fill decisions

RemovePlayerFromQueue followed battleground links and removed seated
participants from running matches; guard with IsActivePlayer. Add the
missing observability: backfill invites (per-team active/invited counts),
rejected join confirmations (a desync source behind an observed 11v10),
and invite expirations.
Copilot AI lite review requested due to automatic review settings August 30, 2026 13:38

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

There is a confirmed high-impact correctness risk around taking the address of a range variable (&bg) plus missing tests for the new “don’t yank active players” guard and link-unlink scoping concerns.

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

Pull request overview

This PR fixes a queue-removal edge case that could incorrectly eject active battleground participants, and adds trace logging to make backfill/invite-related desyncs (e.g., 11v10) diagnosable.

Changes:

  • Add backfill decision logs (per team) when inviting groups into in-progress battlegrounds.
  • Log and surface errors when join confirmations are rejected, and prevent RemovePlayerFromQueue from removing active/seated battleground participants.
  • Add invite-expiration logging and attempt to limit invite-expiry cleanup to the affected battleground.
File summaries
File Description
apps/matchmakingserver/service/battleground-queue.go Adds backfill invite tracing; review also flags a correctness issue around passing &bg from a range loop.
apps/matchmakingserver/service/battleground_service.go Adds join-rejection logging, prevents queue removal from yanking active players, and adds invite-expiry tracing/unlinking.
apps/matchmakingserver/battleground/battleground.go Adds IsActivePlayer helper used to guard queue-removal behavior.
Review details

Suppressed comments (1)

apps/matchmakingserver/service/battleground-queue.go:179

  • Same as above: this backfill trace is on a hot path and can spam Info logs under load; Debug (or sampling) is usually safer for per-iteration decisions.
				log.Info().
  • Files reviewed: 3/3 changed files
  • Comments generated: 5
  • Review effort level: Lite

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

if freeSlotsAlliance > 0 {
groupsToInvite := q.findGroupsForGivenSlots(freeSlotsAlliance, battleground.TeamAlliance)
if len(groupsToInvite) > 0 {
log.Info().
Comment on lines +199 to +203
// IsActivePlayer reports whether the player is a seated participant.
func (b *Battleground) IsActivePlayer(playerGUID uint64, realmID uint32) bool {
unwrappedGUID := guid.PlayerUnwrapped{
RealmID: uint16(realmID),
LowGUID: guid.LowType(playerGUID),
Comment on lines +775 to +779
// "Remove from queue" must never yank a seated participant out of
// a running match — active players leave through
// PlayerLeftBattleground only. Only invite/queue links are undone.
if bg.IsActivePlayer(playerGUID, realmID) {
continue
Comment on lines +883 to +887
s.removeBattlegroundLinkForPlayer(BattlegroundKey{
RealmID: bg.RealmID,
InstanceID: bg.InstanceID,
BattlegroupID: bg.BattleGroupID,
}, uint64(invite.GUID.LowGUID), uint32(invite.GUID.RealmID))
Int("invited", len(bg.InvitedPlayersPerTeam[battleground.TeamAlliance])).
Int("groups", len(groupsToInvite)).
Msg("backfill invites alliance")
q.inviteGroupsToBG(groupsToInvite, &bg, battleground.TeamAlliance)
Review follow-ups: unit tests for Battleground.IsActivePlayer (seated
players only, realm-aware) and for RemovePlayerFromQueue keeping a
seated participant untouched - a regression would either mutate the
battleground state or panic on the fixture's nil events producer.
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