← All projects

Notify Queue

Schedules email, SMS and push, and delivers each one exactly once — even with ten workers polling the same table at the same moment.

Notify Queue: 500 jobs across 10 polling workers with zero duplicates using FOR UPDATE SKIP LOCKED, against the control test where a naive SELECT then UPDATE produces duplicates

The problem

Scheduling a notification is the easy half. Delivering it exactly once is the half that goes wrong, and it goes wrong quietly: a duplicate SMS looks like a delivery, not a bug. Nobody files a ticket. The customer just gets told twice, and then charged twice for the privilege if the message was transactional.

The failure only appears under concurrency. One worker is always correct. Ten workers polling the same table for due rows is where two of them read the same job, both decide it is theirs, and both send it.

What I built

The test that matters most is the one designed to fail

A concurrency guarantee nobody has watched break is a guarantee nobody has tested. So alongside the real claim there is a control test that implements the naive SELECT then UPDATE and demonstrates it handing one job to many workers.

Decisions worth naming