Repository navigation
feat(email-service): Retry queue for webhook pubsub processing - #390
Merged
evanhutnik merged 9 commits intoDec 2, 2025
Merged
evanhutnik merged 9 commits into
evanhutnik merged 9 commits into
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 { |
Contributor
There was a problem hiding this comment.
I think it's time to move out the workers into their own container that runs isolated from email service.
Contributor
There was a problem hiding this comment.
please make a ticket for that and implement when you have the bandwidth, medium priority
Contributor
Author
There was a problem hiding this comment.
Comment on lines
+37
to
+39
| Err(anyhow::anyhow!( | ||
| "gmail_webhook_retry_queue is not configured" | ||
| )) |
Contributor
There was a problem hiding this comment.
Prefer anyhow::bail! here
whutchinson98
approved these changes
Dec 2, 2025
whutchinson98
left a comment
Contributor
There was a problem hiding this comment.
small nit but overall seems fine.
we really should be running these workers in a separate container to the main email service though.
evanhutnik
deleted the
evan/ema-42-improve-rate-limit-handling-for-webhook-pubsub-queue
branch
December 2, 2025 16:10
dev-rb
pushed a commit
that referenced
this pull request
Dec 2, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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