-
Notifications
You must be signed in to change notification settings - Fork 13.1k
[FIX][ENTERPRISE] Race condition on Omnichannel queues #19352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sampaiodiego
merged 20 commits into
develop
from
omnichannel/concurrent-chats-limit-feature-failing
Oct 27, 2020
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
eee09ef
Update index.js (#19348)
ggazzo 5cd0bf7
Improve omnichannel waiting queue.
renatobecker b42cf8e
Merge branch 'develop' into omnichannel/concurrent-chats-limit-featur…
renatobecker 505dd8f
Fix imports.
renatobecker 9cfa2ac
Improve aggregation pipeline and added migration.
renatobecker bf67b60
Loop all queues(departments) to process next inquiry.
renatobecker 87ed6ff
Add Migration.
renatobecker 0b07cd6
Fix migration conflict.
renatobecker 0d398b4
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat i…
renatobecker c5d03c8
Fix migration file.
renatobecker 8609c9f
Remove unnecessary index.
renatobecker bcc4d2c
Process only active queues.
renatobecker 83c5d8d
Remove unused import file.
renatobecker f9b4cae
Merge branch 'develop' into omnichannel/concurrent-chats-limit-featur…
renatobecker 710f67f
Review suggestions.
renatobecker 0174671
Fix model definition interface.
renatobecker cd3eb94
Merge branch 'develop' into omnichannel/concurrent-chats-limit-featur…
renatobecker 98b8a19
Remove unnecessary console.log.
renatobecker 949c9ec
Merge branch 'develop' into omnichannel/concurrent-chats-limit-featur…
renatobecker 0893594
Remove unnecessary index.
renatobecker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { Base } from './_Base'; | ||
|
|
||
| export class OmnichannelQueue extends Base { | ||
| constructor() { | ||
| super('omnichannel_queue'); | ||
| } | ||
| } | ||
|
|
||
| export default new OmnichannelQueue(); | ||
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| /* eslint-disable @typescript-eslint/explicit-function-return-type */ | ||
| import { | ||
| Collection, | ||
| } from 'mongodb'; | ||
|
|
||
| import { BaseRaw } from './BaseRaw'; | ||
| import { IOmnichannelQueueStatus } from '../../../../definition/IOmnichannel'; | ||
|
|
||
| const UNIQUE_QUEUE_ID = 'queue'; | ||
| export class OmnichannelQueueRaw extends BaseRaw { | ||
| public readonly col!: Collection<IOmnichannelQueueStatus>; | ||
|
|
||
| initQueue() { | ||
| return this.col.updateOne({ | ||
| _id: UNIQUE_QUEUE_ID, | ||
| }, { | ||
| $unset: { | ||
| stoppedAt: 1, | ||
| }, | ||
| $set: { | ||
| startedAt: new Date(), | ||
| locked: false, | ||
| }, | ||
| }, { | ||
| upsert: true, | ||
| }); | ||
| } | ||
|
|
||
| stopQueue() { | ||
| return this.col.updateOne({ | ||
| _id: UNIQUE_QUEUE_ID, | ||
| }, { | ||
| $set: { | ||
| stoppedAt: new Date(), | ||
| locked: false, | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| async lockQueue() { | ||
| const result = await this.col.findOneAndUpdate({ | ||
| _id: UNIQUE_QUEUE_ID, | ||
| locked: false, | ||
| }, { | ||
| $set: { | ||
| locked: true, | ||
| }, | ||
| }, { | ||
| sort: { | ||
| _id: 1, | ||
| }, | ||
| }); | ||
|
|
||
| return result.value; | ||
| } | ||
|
|
||
| async unlockQueue() { | ||
| const result = await this.col.findOneAndUpdate({ | ||
| _id: UNIQUE_QUEUE_ID, | ||
| }, { | ||
| $set: { | ||
| locked: false, | ||
| }, | ||
| }, { | ||
| sort: { | ||
| _id: 1, | ||
| }, | ||
| }); | ||
|
|
||
| return result.value; | ||
| } | ||
| } |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| export interface IOmnichannelQueueStatus { | ||
| _id: string; | ||
| startedAt: Date; | ||
| stoppedAt?: Date; | ||
| locked: boolean; | ||
| } |
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.