A ticket worker crashes halfway through a four-ticket booking. How does retry recover?
After this you can answer: A ticket worker crashes halfway through a four-ticket booking. How does retry recover?
Say it in 30 seconds
Section titled “Say it in 30 seconds”The deeper answer
Section titled “The deeper answer”For seat one through quantity, the handler derives ticketId from booking ID and seat number. DynamoDB conditionally creates that owner’s ticket record. A competing delivery reads the existing record strongly and uses its stored token. It rejects a changed booking identity rather than silently replacing another record.
If the process stops after reservation, the retry writes the image. If it stops after S3 accepts but before ready is saved, the retry overwrites the same object and marks the record ready. Existing ready records skip S3 entirely. This is a recoverable state machine: each durable state says which work remains.
The API keeps Postgres as booking truth and returns bookings even if asynchronous ticket records are missing. It exposes only validated ready tickets. Production hardening could add reconciliation for old creating records or accidentally deleted objects; the current ready flag alone does not continuously prove that the S3 object still exists.
Counter-questions
Section titled “Counter-questions”What if two workers generate the same seat?
Does a missing QR cancel the booking?
Why not save ready before writing S3?
Where in MiniTickets
Section titled “Where in MiniTickets”Read Lambda worker, then inspect the tickets-table piece →.
apps/worker/src/handlers/tickets.ts → handleTicketsRead this book online: https://book.theversehub.in/