The interview problem

Practice prompt

A task runs longer than its queue visibility timeout and another worker receives it. Design safe completion and recovery.

Original practice, not a reported company interview. Scenarios and numbers are illustrative. Interview date: not applicable. Sources retrieved October 1, 2026.

1. Scope and worked approach

Assume at-least-once delivery and a visibility lease that hides, rather than deletes, a message. Workers heartbeat to extend visibility while making bounded progress, but business effects still use stable operation IDs and transactional deduplication where possible. Delete the message only after durable completion. A worker that loses its lease must stop initiating new effects or be fenced by the destination.

2. Trace the design or derivation

Receive message
  → claim business operation
  → extend while progressing
  → commit effect
  → acknowledge queue

An operation record can distinguish pending, completed and uncertain external outcomes. On redelivery, reconcile an uncertain outcome before issuing another irreversible action. Keep the queue receipt handle separate from the business operation ID because each delivery can receive a different handle while referring to the same intended effect.

3. Calculate the example

A job needs 90 seconds but visibility lasts 30 seconds. Without extension it can be delivered again after 30 seconds while the first copy still runs. Setting visibility to 120 seconds reduces this case but delays recovery from an immediate worker crash.

4. Failure cases and trade-offs

Heartbeat success does not guarantee exclusivity under all delivery semantics. Very long leases hide dead work; short leases increase duplicate execution. Poison jobs need bounded attempts and a diagnosable terminal queue, not endless visibility extensions.

5. Validation, follow-ups and self-review

Crash after an effect but before deletion and pause beyond the lease. Follow-up: what if the external effect lacks idempotency support? Self-review: separate delivery ownership from business-effect uniqueness.

Sources and related practice

Technical reference: docs.aws.amazon.com — Visibility timeout and possible redelivery.

Source publication/update: Not established. Retrieved October 1, 2026. The workflow, calculations and review exercises are original; this reference is not evidence that a company asked this question.

Continue with Design a durable work queue; Design a lease service with fencing tokens.

Continue your preparation

Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.