Queue Ack Lost
The worker commits the business change and crashes before ACK.
Topic tools
Layout updated
Prompt
The worker commits the business change and crashes before .
A receipt can get lost after the work is done. The next worker must recognize the same job before doing that work again.
Constraints
- Do not repeat a committed business effect on redelivery.
- Retain job identities through the supported replay window.
Think first
Take five minutes to state the failure, the evidence you need and your first safe move.
Staged reveal
First move
One transaction records both the effect and which message caused it.
What to check
Correlate message identity with the durable processed-message record.
Recovery
Commit effect and identity in one transaction; on redelivery return the stored result and . An external side effect needs its own or protocol.
What you give up
A unique business key and processed-message history add storage, but let retries return a recorded result instead of guessing whether to repeat the action.
Architecture and technical reference
High-level design
- Messaging
- Compute
- State
━━ Synchronous┄┄ Asynchronous···· Recovery / control▧ Fault
Each arrow is one interaction. Request, background and recovery branches are not one linear transaction.
Read the 4 flow steps
Problem statement
A worker commits a business change and crashes before acknowledging its message. The queue delivers it again.
Functional requirements
- Process a delivered job and record its result.
- Recognize the same job when it is delivered again.
- Acknowledge completed work to the broker.
Non-functional requirements
- Do not repeat a committed business effect on redelivery.
- Retain job identities through the supported replay window.
Entities
| Entity / logical owner |
|---|
| Authoritative state |
API design
| Operation / input | Response and retry contract |
|---|---|
Decision contract | Identify acceptance, retry identity, version/ and the response on uncertainty. |
High-level design component walkthrough
RabbitMQ Durable Queue
May redeliver after lost
Why, tradeoff and connected operations
queue, publisher confirms and manual after the PostgreSQL effect/identity transaction. Buffer independent producers and consumers, with bounded and replay semantics.
Tradeoff: At-least-once means replay
Connected operations: Consume work
Worker
Process messageId
Why, tradeoff and connected operations
Isolate this operation so it can scale and fail independently from storage.
Tradeoff: Crash after side effect before
Connected operations: Consume work; One effect + dedup transaction
PostgreSQL / Idempotency Store
processed key
Why, tradeoff and connected operations
: PostgreSQL. Relational tables and constraints own this state. Logical tables shown within the same business database are not separate databases; only at the defined transaction boundary. Use transactional constraints for related authoritative records; indexes follow the access pattern.
Tradeoff: Needs durable transaction
Connected operations: One effect + dedup transaction; Same DB transaction
PostgreSQL / Business Side Effect
Exactly once logically
Why, tradeoff and connected operations
: PostgreSQL. Relational tables and constraints own this state. Logical tables shown within the same business database are not separate databases; only at the defined transaction boundary. Use transactional constraints for related authoritative records; indexes follow the access pattern.
Tradeoff: External may lack
Connected operations: Same DB transaction; Publish event
RabbitMQ Consumer ACK
Only after commit
Why, tradeoff and connected operations
A protocol acknowledgement after commit; not a separate queue or database. Buffer independent producers and consumers, with bounded and replay semantics.
Tradeoff: Lost acknowledgment repeats delivery
Connected operations: Publish event
Engineering control room
Deep dives — decisions, failures and recovery
Open a deep dive to follow the steps, try an example and see how recovery works.
Tradeoffs and alternatives
| Decision | Tradeoff / alternative and recovery implication |
|---|---|
| Commit the job identity with the business change | A unique business key and processed-message history add storage, but let retries return a recorded result instead of guessing whether to repeat the action. |
| Return the saved result after a lost | Keep processed identities through the archive-replay window. Deleting them early can make an old charged order appear to be new work. |
| What happens if a region fails? | Remote durability costs latency and storage; losing that evidence creates uncertainty that a fresh empty set cannot solve. |
| and replay contracts | Long costs storage and lookup work; shorter restricts replay and requires an auditable recovery procedure. |
Production scars & failure modes
The worker commits the business change and crashes before ACK.
Look for: Correlate message identity with the durable processed-message record.
Recovery and invariant: Commit effect and identity in one transaction; on redelivery return the stored result and . An external side effect needs its own or protocol.
| Component / failure | Impact | Recovery mechanism | Alternative / tradeoff |
|---|---|---|---|
| Primary failure / race | A worker commits a business change and crashes before acknowledging its message. The queue delivers it again. | On replay, return the stored result without repeating the effect. For an external , reuse a provider-supported key and reconcile unknown outcomes. | A separate SETNX reservation before the effect can lose work on crash; -before-effect can also lose work. |
| Recovery follow-up | The dedup record is deleted before an old archived message is replayed. State a replay/ policy. | On replay, return the stored result without repeating the effect. For an external , reuse a provider-supported key and reconcile unknown outcomes. | State the guarantee you relax and how you detect recovery. |
90-second interview summary
For a lost queue acknowledgement, I would assume redelivery is normal and protect the business effect instead of trying to eliminate every repeated message. The worker uses a stable logical identity and commits the business mutation, processed-message record and stored result in one transaction.
If it crashes before commit, there is no effect and another worker may retry. If it crashes after commit but before , redelivery finds the stored result and does not repeat the effect. Concurrent consumers meet the same unique transaction boundary; an in-memory check or separate write leaves a gap.
External effects require a different boundary. A payment or email provider cannot automatically share the local transaction, so the worker records a stable attempt key and reconciles uncertain outcomes under the provider's actual support.
I would retain processed identities through the supported retry/archive-replay window and recover them alongside business state during regional failover. Missing evidence is not permission to repeat an uncertain action. Metrics include duplicate suppression, old unresolved attempts and replay age. The tradeoff is retained identity state and recovery work in exchange for explaining why a lost receipt does not become a second charge or another committed business change.
Explain it without looking
Explain commit the job identity with the business change
Reveal answer
One transaction records both the effect and which message caused it.
Writing a separate reservation before the effect can lose work; acknowledging before commit can also lose it.
A unique business key and processed-message history add storage, but let retries return a recorded result instead of guessing whether to repeat the action.
Explain return the saved result after a lost
Reveal answer
On redelivery, recognize committed work before doing it again.
The broker can deliver again even though the first worker successfully committed.
Keep processed identities through the archive-replay window. Deleting them early can make an old charged order appear to be new work.
Explain what happens if a region fails?
Reveal answer
Recover processed-job records with their business changes before replaying jobs.
At-most-once business effects require the evidence to survive alongside the effect.
Remote durability costs latency and storage; losing that evidence creates uncertainty that a fresh empty set cannot solve.
Explain and replay contracts
Reveal answer
Keep processed identities for the entire supported repeat-delivery window.
A correct algorithm can still repeat effects when the evidence it depends on has expired.
Long costs storage and lookup work; shorter restricts replay and requires an auditable recovery procedure.
Revision checklist
Revision checklist
- Reconstruct commit the job identity with the business change: One transaction records both the effect and which message caused it.
- Reconstruct return the saved result after a lost : On redelivery, recognize committed work before doing it again.
- Reconstruct what happens if a region fails?: Recover processed-job records with their business changes before replaying jobs.
- Reconstruct and replay contracts: Keep processed identities for the entire supported repeat-delivery window.
- Name the authoritative state, boundary, retry identity and failure-domain durability guarantee.
- Explain one alternative and exactly which guarantee you would relax.
- Redraw the request and recovery paths without looking; mark what required a hint.
On this page
- Prompt
- Constraints
- Think first
- Staged reveal
- High-level design
- Problem statement
- Functional requirements
- Non-functional requirements
- Entities
- API design
- High-level design component walkthrough
- Engineering control room
- Deep dives — decisions, failures and recovery
- Tradeoffs and alternatives
- Production scars & failure modes
- 90-second interview summary
- Explain it without looking
- Revision checklist