Skip to content

feat: implement mutex for SlackSendJob - #7783

Merged
scmmishra merged 13 commits into
developfrom
feat/slack-lock-cw-2043
Aug 25, 2023
Merged

scmmishra merged 13 commits into
developfrom
feat/slack-lock-cw-2043

Conversation

@scmmishra

@scmmishra scmmishra commented Aug 23, 2023 •

Copy link
Copy Markdown
Member

This PR implements redis based mutex for SlackSendJob


This PR has the following changes

  1. Implement mutex for Slack send job.
  2. Create MutexApplicationJob that exposes with_lock
  3. Refactor facebook_events_job to use the new MutexApplicationJob

@netlify

netlify Bot commented Aug 23, 2023 •

Copy link
Copy Markdown

✅ Deploy Preview for chatwoot-storybook canceled.

Name Link
🔨 Latest commit 839593d
🔍 Latest deploy log https://app.netlify.com/sites/chatwoot-storybook/deploys/64e73ca6e7c7df00080f3bf4

@scmmishra scmmishra changed the title feat: Mutex for slack sending job feat: implement LockManager for Slack sending job Aug 23, 2023
@scmmishra
scmmishra marked this pull request as ready for review August 23, 2023 05:46
@scmmishra scmmishra changed the title feat: implement LockManager for Slack sending job feat: implement mutex for SlackSendJob Aug 23, 2023

@sojan-official sojan-official left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went through the code, and it looks good to me.
Let's merge it after testing.

@scmmishra
scmmishra temporarily deployed to staging-chatwoot August 24, 2023 10:26 Inactive
@scmmishra

scmmishra commented Aug 24, 2023 •

Copy link
Copy Markdown
Member Author

@sojan-official tested this on staging. To replicate, try sending multiple messages really one after the other really fast.

Before mutex CleanShot 2023-08-24 at 17 26 28@2x CleanShot 2023-08-24 at 17 26 35@2x

After the deploy, the mutex "partially" works, multiple messages are not triggered on slack. But there is still some problem with setting the context, replies on slack don't show up. Will test that and see if it's a config issue or a bug

Turns out it was some processing delay on sidekiq, @sojan-official is it because slack send job is on the medium queue? or should I investigate this?

The solution works fine. Here's the logs that show the whole dance for acquiring locks

CleanShot 2023-08-24 at 18 11 02@2x
After fix CleanShot 2023-08-24 at 18 15 07@2x CleanShot 2023-08-24 at 18 14 38@2x

@scmmishra
scmmishra merged commit 5598b4b into develop Aug 25, 2023
@scmmishra
scmmishra deleted the feat/slack-lock-cw-2043 branch August 25, 2023 04:58
rutvijmehta-harness pushed a commit to rutvijmehta-harness/chatwoot that referenced this pull request Aug 30, 2023
rutvijmehta-harness added a commit to rutvijmehta-harness/chatwoot that referenced this pull request Aug 30, 2023
Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
@sentry

sentry Bot commented Aug 31, 2023 •

Copy link
Copy Markdown

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ MutexApplicationJob::LockAcquisitionError: Failed to acquire lock for key: SLACK_MESSAGE_LOCK::::C05KE826D8C (MutexApplicationJob::LockAcqui... Sidekiq/SendOnSlackJob View Issue
  • ‼️ MutexApplicationJob::LockAcquisitionError: Failed to acquire lock for key: FB_MESSAGE_CREATE_LOCK::182015432606460::6547625415327867 (MutexA... Sidekiq/Webhooks::FacebookEventsJob View Issue
  • ‼️ MutexApplicationJob::LockAcquisitionError: Failed to acquire lock for key: SLACK_MESSAGE_LOCK::3851376::C02C7P6KE06 (MutexApplicationJob::Lo... Sidekiq/SendOnSlackJob View Issue

Did you find this useful? React with a 👍 or 👎

rutvijmehta-harness pushed a commit to rutvijmehta-harness/chatwoot that referenced this pull request Aug 31, 2023
rutvijmehta-harness added a commit to rutvijmehta-harness/chatwoot that referenced this pull request Aug 31, 2023
Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
@github-actions

github-actions Bot commented Oct 1, 2023

Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Oct 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants