-
Notifications
You must be signed in to change notification settings - Fork 3
feat(email-service): Retry queue for webhook pubsub processing #390
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
feat(email-service): Retry queue for webhook pubsub processing #390
Conversation
…webhook-pubsub-queue
…webhook-pubsub-queue
| ); | ||
|
|
||
| // separate queue for retries to avoid backups for large inbox updates that hit gmail api rate limit | ||
| for worker in webhook_retry_workers { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's time to move out the workers into their own container that runs isolated from email service.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please make a ticket for that and implement when you have the bandwidth, medium priority
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed, will do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Err(anyhow::anyhow!( | ||
| "gmail_webhook_retry_queue is not configured" | ||
| )) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer anyhow::bail! here
whutchinson98
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small nit but overall seems fine.
we really should be running these workers in a separate container to the main email service though.
Summary
Adding separate retry queue for gmail inbox update pubsub processing.
Problem
When users perform bulk operations (e.g., archiving 10,000 emails), we have to make separate calls to the Gmail API for each message being updated, which results in us hitting the rate limit quota for the user, in turn causing webhook processing to repeatedly retry. This creates a backlog that delays inbox updates for all users, not just the one performing the bulk operation, as all of these messages were being processed by the same workers.
Solution
Implement a two-tier webhook processing system:
This architecture prevents head-of-line blocking—the primary queue continues processing fresh updates for all users while rate-limited operations are handled independently.
Changes
maxReceiveCountto improve chance it doesn't dlq)check_gmail_rate_limit_webhook()helper to deduplicate rate limit handling logicTesting
Verified in dev environment:
Screenshots, GIFs, and Videos