Relationships
#3994 Five Mongo queues can hand the same row to two replicas
Opened by skunk-ape · 10/26/2026
Problem
Five Mongo queues claim work by a find followed by a separate updateMany that marks the rows processing. Every replica runs their watchers, so two replicas that poll between each other's find and updateMany both take the same rows.
- lib/infrastructure/mongo-feed-judge-queue.ts
- lib/infrastructure/mongo-attio-sync-queue.ts
- lib/infrastructure/mongo-resend-contact-queue.ts
- lib/infrastructure/mongo-system-message-queue.ts
- lib/infrastructure/mongo-returning-trial-queue.ts
Depending on the queue, a duplicate claim judges a feed submission twice, syncs a CRM record twice, or sends a message or email twice.
Expected
Each row is claimed by exactly one replica: one findOneAndUpdate per row, as mongo-inbox-email-queue.ts claimPending already does, keeping the 5 minute stale-processing reclaim. Check each queue's batch size against that window: a batch claimed at once but processed serially can outlast it and be reclaimed while still queued in memory.
Found while triaging swamp-club#3979, which fixes the same race in the extension scoring queue.
Open
No activity in this phase yet.
Sign in to post a ripple.