Can you guarantee exactly one confirmation email per booking?
After this you can answer: Can you guarantee exactly one confirmation email per booking?
Say it in 30 seconds
Section titled “Say it in 30 seconds”The deeper answer
Section titled “The deeper answer”The email job key identifies the business effect: booking.confirmed for one booking. DynamoDB reads are strongly consistent, and the completion write is conditional. Those details stop stale completion reads and conflicting writes; they do not reserve the job before sending.
Two workers can both read no completion record, both send, and then race to record completion. Only one record is created, but two external effects may already have happened. A single worker can also send successfully and fail before saving completion.
Records carry a thirty-day TTL for eventual cleanup, so duplicate suppression is not permanent history. A manual replay after the record disappears can send again. A lease could reduce simultaneous sends, but a crashed sender with an uncertain provider outcome still needs a policy. Also distinguish provider acceptance from actual inbox delivery: neither this record nor a successful API call proves receipt.
Counter-questions
Section titled “Counter-questions”Why not mark completion before sending?
Would a conditional put after send stop the race?
What would you promise the product team?
Where in MiniTickets
Section titled “Where in MiniTickets”Read Dynamodb, then inspect the processed-jobs-table piece →.
apps/worker/src/handlers/booking-confirmed.ts → handleBookingConfirmed
Compare the duplicate-email case.
Read this book online: https://book.theversehub.in/