Repository navigation
Fix expired peer cleanup and disconnect handling - #409
Merged
Merged
Conversation
Tic Tac Toe Ultimate is generating peers quicker than our cleanup process can currently handle. The game is very popular. Clean up expired peers in batches of 250 and update each affected lobby once per batch. Add a GIN index for lobby membership lookups and elect replacement leaders once per affected lobby. Replace the startup timestamp reset with a reconnect grace period so restarts don't revive stale peers or block reconnections. Mark peers disconnected on explicit close and prevent late heartbeats from refreshing them. Cancel connections after failed pings and bound heartbeat database updates with a timeout.
Track the current connection ID for each peer and ignore heartbeats and disconnects from older connections. This prevents delayed cleanup from marking a healthy reconnected peer as disconnected. Run empty lobby cleanup every five minutes and add a partial index for empty lobbies. Include the connection ID in the existing cleanup migration and remove concurrent index creation.
Pedr0Rocha
approved these changes
Oct 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tic Tac Toe Ultimate is generating peers quicker than our cleanup process can currently handle. The game is very popular.
Clean up expired peers in batches of 250 and update each affected lobby once per batch. Add a GIN index for lobby membership lookups and elect replacement leaders once per affected lobby.
Replace the startup timestamp reset with a reconnect grace period so restarts don't revive stale peers or block reconnections.
Mark peers disconnected on explicit close and prevent late heartbeats from refreshing them. Cancel connections after failed pings and bound heartbeat database updates with a timeout.