A customer gets two welcome emails. The queue dashboard shows one completed job. Weird, until you look at what happened between the send and the acknowledgement.

In this example, a worker sends the email, the provider accepts it, and the worker crashes before acknowledging the queue message. The queue delivers the message again. Another worker sends the same email. The dashboard eventually shows one completed job, while the provider shows two accepted sends.

Trace the logical notification

Search by the notification ID across the queue, worker and email provider. Put the job attempts, provider request IDs and timestamps on one timeline. Distinguish a duplicate incoming event from a second attempt at the same job. Inspect the provider's records before treating a timeout as proof that the email never went out.

Use the same key on every retry

Represent the intended send with a stable key such as welcome:account-42:v1. Keep it the same across attempts. Use a database uniqueness constraint to prevent two notification records with the same key. If the email provider supports idempotency keys, pass the same key there too and check its retention window.

A local unique row alone cannot settle a crash after the provider accepts a send. When the outcome is unclear and the provider cannot safely deduplicate the retry, reconcile with provider records if available. Otherwise, send it to a manual review queue instead of silently treating it as unsent.

Test the awkward moment

In a test environment, make a fake provider accept the send and then simulate a lost response. Replay the job with the same key. Check that the provider records one logical send where deduplication applies, or that the item becomes an explicit reconciliation task. Also test a genuinely different notification to ensure it still gets through.

If a database write should reliably create the job, put an outbox record in the same transaction. The relay can still produce duplicate messages, so keep the consumer safeguards as well.

Which ID would you search first if a customer sent you screenshots of two identical emails?

Further reading: AWS on transactional outboxes · Umer Amin Durrani’s portfolio

Text and cover illustration generated with AI.