Skip to content

Fix expired peer cleanup and disconnect handling - #409

Merged
erikdubbelboer merged 2 commits into
mainfrom
improve-peer-cleanup
Oct 24, 2026
Merged

erikdubbelboer merged 2 commits into
mainfrom
improve-peer-cleanup

Conversation

@erikdubbelboer

Copy link
Copy Markdown
Member

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.

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.
@erikdubbelboer
erikdubbelboer enabled auto-merge (squash) October 24, 2026 15:50
@erikdubbelboer
erikdubbelboer merged commit 386f2ed into main Oct 24, 2026
8 checks passed
@erikdubbelboer
erikdubbelboer deleted the improve-peer-cleanup branch October 24, 2026 15:51
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