Fix: duplicate connections inserted for a usersSession #54
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.
When digging into an issue where our users were showing as always online. We took the approach of regularly cleaning up any 'stale' usersSessions since especially during deploys we noticed that certain usersSessions were not getting removed even though the instances no longer existed in the instances collection.
Here is a screenshot of the cleanup batch job:
It seems like the logic here does not run on our aws deploys since the users that are stuck in this permanently online state seem to be connected to instances that no longer exist.
A secondary and perhaps minor issue we noticed was that usersSessions had duplicate connections to the same instance with the same connectionId:
This PR fixes that duplicate connection issue.