#221 Presence recovery after gateway restart FIXED#262
Open
felladaniel36-hash wants to merge 1 commit into
Open
#221 Presence recovery after gateway restart FIXED#262felladaniel36-hash wants to merge 1 commit into
felladaniel36-hash wants to merge 1 commit into
Conversation
|
@felladaniel36-hash Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Owner
|
Hello @felladaniel36-hash |
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.
Description
This PR resolves an issue where online presence tracking and room subscriptions were lost during a gateway (backend instance) restart.
Specifically, it introduces three key changes:
SIGTERM,SIGINT,httpServer.close(),io.close()) to set anisShuttingDownflag. During a server shutdown or namespace restart,socket.on('disconnect')skips assertingsetOffline(), preserving active user presence mappings in Redis.reconcileBoot): Adds a reconciliation routine that runs on gateway boot once the Socket.IO Redis adapter attaches. It scans activepresence:*keys in Redis, queries PostgreSQL for user conversation memberships, and rebuilds room subscriptions viaio.in(socketId).socketsJoin(conversationId).cleanupStaleSockets): On socket connection, heartbeat, and disconnect, existing socket IDs stored inpresence:{userId}are checked against active sockets in the cluster (io.in(sid).fetchSockets()). Dead sockets from prior restarts are purged immediately, preventing duplicate presence entries.Type of change
Bug fix
New feature
Documentation update
Other
Checklist
I have read the contributing guidelines
I have tested my changes locally
My code follows the project's coding standards
CLOSE #221