Skip to content

Fix referees not being correctly dissociated from closed rooms in specific scenario - #543

Merged
peppy merged 1 commit into
ppy:masterfrom
bdach:fix-dangling-referee-rooms
Oct 6, 2026
Merged

peppy merged 1 commit into
ppy:masterfrom
bdach:fix-dangling-referee-rooms

Conversation

@bdach

@bdach bdach commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Should close #541.

The scenario here is as follows:

  1. Referee A and B are in a room. (It does not matter which created the room / is host, or in what order they joined.)
  2. Referee A drops connection to the hub, therefore leaving the room. Since Delay closing tournament rooms for 30min after last user left #466, this is no longer synonymous with losing referee privileges to the room - they are retained as spectator server memory state.
  3. While referee A still has refereeing privileges but still has not rejoined the room, B disbands the room.
  4. Referee A will now show as still associated to the room despite it being closed.

The reason for this bug is an oversight. The room disband operation relied on iterating over room.Users to clean up all users' state. This was safe to do prior to #466, because a referee drop-out would automatically incur a full leave including privilege revocation, but is not safe to do any more.

To address this, change to a somewhat naive loop over all referees in the hub that ensures every single remaining one is dissociated from the closed room. I am not going to defend how it looks too hard, though extenuating circumstances here include:

  • this hub is concurrently used by double-digit clients at the absolute most at this time,
  • room closes should be relatively rare operations.

If despite the above the fix is still considered too offensive to live, I will attempt to conjure some sort of inverse memory-state association that will allow to access all referees in a room in closer-to-constant time.

…cific scenario

Should close ppy#541.

The scenario here is as follows:

1. Referee A and B are in a room. (It does not matter which created the
   room / is host, or in what order they joined.)
2. Referee A drops connection to the hub, therefore leaving the room.
   Since ppy#466, this is
   no longer synonymous with losing referee privileges to the room -
   they are retained as spectator server memory state.
3. While referee A still has refereeing privileges but still has not
   rejoined the room, B disbands the room.
4. Referee A will now show as still associated to the room despite it
   being closed.

The reason for this bug is an oversight. The room disband operation
relied on iterating over `room.Users` to clean up all users' state. This
was safe to do prior to
ppy#466, because a referee
drop-out would automatically incur a full leave including privilege
revocation, but is not safe to do any more.

To address this, change to a somewhat naive loop over all referees in
the hub that ensures every single remaining one is dissociated from the
closed room. I am not going to defend how it looks too hard, though
extenuating circumstances here include:

- this hub is concurrently used by double-digit clients at the absolute
  most at this time,
- room closes should be relatively rare operations.

If despite the above the fix is still considered too offensive to live,
I will attempt to conjure some sort of inverse memory-state association
that will allow to access all referees in a room in closer-to-constant
time.
@bdach bdach self-assigned this Oct 6, 2026

@peppy peppy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fine for the time being

@peppy
peppy merged commit 66141f0 into ppy:master Oct 6, 2026
2 checks passed
@bdach
bdach deleted the fix-dangling-referee-rooms branch October 6, 2026 13:13
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.

ListRooms returns closed rooms after AddReferee

2 participants