feat: locking and retry in FB message parsing#7701
Conversation
✅ Deploy Preview for chatwoot-storybook canceled.
|
sojan-official
left a comment
There was a problem hiding this comment.
LGTM overall. some minor comments on code organisation.
|
@sojan-official LMK your thoughts on the key used to acquire the lock? Also about the lock timings, I was thinking we can increase the lock timeout to about 30 seconds |
sojan-official
left a comment
There was a problem hiding this comment.
LGTM overall .
Some minor comments. let's have this added for whatsapp messages as well as a follow up
ref: #5433
|
@sojan-official tests are all done, just need to take a look at the key used for locking and we're good to go |
|
The code looks good to me. Let's test this on staging and then get it merged. |
|
@sojan-official tested this on staging, working fine. We're good to merge this |
|
@sojan-official the breaking test is because of a security audit. This PR solves it #7765 |
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
|
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. |
This PR adds a Redis based lock for Facebook message processing to avoid race conditions/concurrent processing of messages from the same sender.
This PR adds the
Redis::LockManager, it provides a simple mechanism to handle distributed locks using Redis. example usageThis also adds a new namespace pool called
$sherlock, our key solver. This is added to ensure that locks don't collide anywhere.The LockManager is used in
Webhooks::FacebookEventsJob, which uses the [retry_on](# https://edgeapi.rubyonrails.org/classes/ActiveJob/Exceptions/ClassMethods.html#method-i-retry_on) method to retry the message creation at least 5 times, with a 10 second backoff.TODO