fix: race condition when forwarding livechat by splitting subscription removal#33381
Merged
fix: race condition when forwarding livechat by splitting subscription removal#33381
Conversation
Contributor
|
Looks like this PR is ready to merge! 🎉 |
🦋 Changeset detectedLatest commit: a0b1672 The changes in this PR will be included in the next version bump. This PR includes changesets to release 33 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #33381 +/- ##
===========================================
- Coverage 58.35% 58.35% -0.01%
===========================================
Files 2692 2692
Lines 65264 65265 +1
Branches 14729 14730 +1
===========================================
Hits 38084 38084
- Misses 24402 24403 +1
Partials 2778 2778
Flags with carried forward coverage won't be shown. Click here to find out more. |
matheusbsilva137
previously approved these changes
Sep 27, 2024
sampaiodiego
requested changes
Sep 27, 2024
sampaiodiego
approved these changes
Sep 27, 2024
matheusbsilva137
approved these changes
Sep 27, 2024
KevLehman
approved these changes
Sep 27, 2024
ggazzo
approved these changes
Sep 27, 2024
Member
|
/patch |
Contributor
|
Pull request #33389 added to Project: "Patch 6.12.2" |
Merged
gabriellsh
added a commit
that referenced
this pull request
Sep 30, 2024
…ocket.Chat into feat/airgapped-restrictions * 'feat/airgapped-restrictions' of github.com:RocketChat/Rocket.Chat: (57 commits) fix: Async E2EE key exchange not working on develop (#33378) chore: Move Apps-Engine to monorepo (#32951) chore(Sidepanel): uses only local channels and discussions (#33387) chore: add gazzodown preview (#33279) fix: Avoid notifying `watch.settings` on uncaught errors (#33376) fix: race condition when forwarding livechat by splitting subscription removal (#33381) chore: Single Contact ID: improved typings and removed some duplicated code (#33324) ci: remove Jira-GitHub security integration (#33384) chore: add ui-composer to storybook (#33383) regression: `Sidepanel` sort requires refresh after room update (#33370) ci: use node20 for release action (#33343) Bump rocket.chat to 6.14.0-develop (#33366) chore: replace Meteor._localStorage -> Accounts.storageLocation (#33356) Release 6.13.0-rc.1 fix: Avoid destructuring `connectionData` when value is undefined (#33339) feat: Adds new admin feature preview setting management (#33212) regression: `Sidepanel` color highlight (#33342) chore: move common files to core-services (#33341) feat: Adds new admin feature preview setting management (#33212) chore: create network broker package (#33338) ...
This was referenced Oct 20, 2024
Closed
Closed
Merged
abhinavkrin
pushed a commit
that referenced
this pull request
Oct 25, 2024
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.
As noted in CORE-696, when a livechat agent forwards a user to another department or agent, the user's chat can sometimes remain stuck in the sidebar of the old agent. Upon investigation, it was found that the old agent (the one forwarding the user) doesn't receive the expected socket event for the subscription deletion, which is crucial for clearing the user from their sidebar.
This issue was introduced in #32540 with the implementation of the
BaseRaw.findOneAndDeletemethod, which is intended to remove a record from a collection and move it to the corresponding trash collection. However, due to the behavior of the RocketChat server's DB Watcher, between the deletion of the record and its insertion into the trash collection, the MongoDB change stream triggers a notification that initiates the DB Watcher flow. The DB Watcher then receives the subscription's trash ID and attempts to find it in the trash collection. At this point, however, the record hasn’t yet been inserted, resulting in a null response. Consequently, the notification of the subscription removal is lost, leaving the user's chat stuck in the old agent's sidebar.Proposed changes (including videos or screenshots)
This PR modifies the flow of the
findOneAndDeletemethod to first insert the removed document into the trash collection before deleting it from the original collection. Additionally, a rollback condition has been implemented to revert the removal if the trash insertion fails.Further comments
Shoutout to @matheusbsilva137 and @sampaiodiego for their help in investigating and identifying the root cause of the problem. Your contributions were invaluable!