Skip to content
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

Contact locking during message handling needs improvement #331

Open
nicpottier opened this issue Sep 9, 2020 · 0 comments
Open

Contact locking during message handling needs improvement #331

nicpottier opened this issue Sep 9, 2020 · 0 comments

Comments

@nicpottier
Copy link
Collaborator

So that we don't handle multiple messages at the same time for the same contact we make sure to get a lock before moving forward with handling it:
https://github.com/nyaruka/mailroom/blob/master/tasks/handler/worker.go#L98

Right now this is configured to wait up to five minutes for the lock, which seems like way too long, especially if a contact has a lot of pending messages that may cause us to lock up many threads waiting to get the lock.

We should explore whether we can just exit immediately and re-queue the handling. Message handling already processes all messages it can find for a contact at once so there isn't a real need to be so determined to get the lock here. Adding an extra contact handle event to the queue when we fail to get the lock should be no problem at all and gives our threads the opportunity to work on something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant