System Design Atlas
LOCAL GUEST MODERead and practice without an account.

Your saved topics and reading progress stay in this browser. Sign in to sync supported profile and progress data.

Queue Ack Lost

The worker commits the business change and crashes before ACK.

◐ MediumDrill 031 min1 prerequisite
My progress
Topic tools

Layout updated

Explore the design, then rehearse the decisions without looking.

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.

5:00

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

Queue Lost
G queue->worker 1. Consume work worker->idem 2. One effect + dedup transaction idem->side 3. Same DB transaction side->ack 4. Publish event queue → RabbitMQ Durable Queue messaging worker Worker compute idem PostgreSQL / Idempotency Store state · durable side PostgreSQL / Business Side Effect state · durable ack RabbitMQ Consumer ACK compute
  • Messaging
  • Compute
  • State

━━ Synchronous┄┄ Asynchronous···· Recovery / control▧ Fault

Select a component or follow a numbered connection.

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 / inputResponse and retry contract
Decision contractIdentify acceptance, retry identity, version/ and the response on uncertainty.

High-level design component walkthrough

Queue / event stream

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

Backend service

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

Relational database

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

Relational database

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

Backend service

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.

Deep dive 1

Commit the job identity with the business change

One transaction records both the effect and which message caused it.

Read the explanation and worked example
How it works

Choose a stable logical message identity and protect it with a unique processed-record constraint. Put the business mutation, processed identity and stored result in one transaction. Checking an in-memory set before updating the database leaves a crash and concurrency gap.

Walk through an example

Two consumers receive the same message after a expires. The unique transaction boundary allows one effect, while the other finds the already committed identity/result.

Failure and recovery

Keep the identity longer than the supported redelivery/replay horizon. If dedup history is deleted too soon, a very old replay can legitimately look new to the database.

Why this helps

Writing a separate reservation before the effect can lose work; acknowledging before commit can also lose it.

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.

Deep dive 2

Return the saved result after a lost ACK

On redelivery, recognize committed work before doing it again.

Read the explanation and worked example
How it works

After commit, acknowledge the broker. If that acknowledgement is lost, the next delivery checks the processed identity and returns the prior result without repeating the effect. Before commit, a crash leaves no effect and the broker is allowed to redeliver.

Walk through an example

A worker adds money to a ledger, commits, then dies before . Redelivery is expected; avoiding it is not the correctness mechanism. The stored identity is.

Failure and recovery

For an external , reuse the provider request key and reconcile unknown outcomes. Do not mark a message processed before an external send and assume that prevents both loss and duplication.

Why this helps

The broker can deliver again even though the first worker successfully committed.

What you give up

Keep processed identities through the archive-replay window. Deleting them early can make an old charged order appear to be new work.

Deep dive 3

What happens if a region fails?

Recover processed-job records with their business changes before replaying jobs.

Read the explanation and worked example
How it works

Preserve processed-message identities and business effects in the same recovered transaction history. Queue failover can redeliver old work, so a region switch must not reset as if every message were new.

Walk through an example

The broker replays a charged order into a region whose store is stale.

Failure and recovery

Fence the old effect owner, reconcile the committed order/provider identity and pause uncertain effects until evidence is restored. Keep supported retry history through the failover window.

Why this helps

At-most-once business effects require the evidence to survive alongside the effect.

What you give up

Remote durability costs latency and storage; losing that evidence creates uncertainty that a fresh empty set cannot solve.

Deep dive 4

Deduplication retention and replay contracts

Keep processed identities for the entire supported repeat-delivery window.

Read the explanation and worked example
How it works

Define how long brokers, archives and clients may replay the same logical message. Retain the processed identity and stored result at least through that period, or require a new replay generation with an explicit rule. Cleanup is part of correctness, not just storage maintenance.

Walk through an example

A year-old archive is replayed after the processed-message table was cleaned at 30 days. The old charge now appears new to the transaction boundary.

Failure and recovery

Block unsupported replay or reconcile against a durable business identity such as the unique order/ledger key. Test cleanup boundaries as carefully as worker crashes.

Why this helps

A correct algorithm can still repeat effects when the evidence it depends on has expired.

What you give up

Long costs storage and lookup work; shorter restricts replay and requires an auditable recovery procedure.

Tradeoffs and alternatives

DecisionTradeoff / alternative and recovery implication
Commit the job identity with the business changeA 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 contractsLong costs storage and lookup work; shorter restricts replay and requires an auditable recovery procedure.

Production scars & failure modes

Failure investigation

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 / failureImpactRecovery mechanismAlternative / tradeoff
Primary failure / raceA 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-upThe 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
  1. Prompt
  2. Constraints
  3. Think first
  4. Staged reveal
  5. High-level design
  6. Problem statement
  7. Functional requirements
  8. Non-functional requirements
  9. Entities
  10. API design
  11. High-level design component walkthrough
  12. Engineering control room
  13. Deep dives — decisions, failures and recovery
  14. Tradeoffs and alternatives
  15. Production scars & failure modes
  16. 90-second interview summary
  17. Explain it without looking
  18. Revision checklist

Save & sync your Atlas progress

Sync your profile and topic progress across browsers, then return to the same study desk.

Google sign-in will appear here after its Azure provider is configured.

Architecture diagram