Skip to content
Preptima
hardScenarioDesignConceptMidSeniorStaff

An Android app queues actions while offline. After the process is killed and restarted, some actions sync twice and the user sees duplicate orders. How do you design the fix?

The queue records that work was sent but cannot know whether the server received it, so any crash between sending and recording the acknowledgement replays the action. At-least-once delivery is the only thing a mobile client can guarantee, so the fix is to make the operation idempotent with a client-generated key persisted alongside the queued action, not to try harder to deliver exactly once.

4 min readUpdated 2026-08-16Target archetype: Product Startup, Big Tech, Enterprise Captive

Answer

Short answer

There is a window between the request leaving the device and the acknowledgement being durably written to the queue. If the process dies inside it, the action is still marked pending and gets replayed on restart — even though the server already applied it. No amount of care closes that window, because the client cannot distinguish "the server never received it" from "the server received it and the response was lost." The fix is to accept at-least-once delivery and make the operation idempotent.

Was this answer helpful?

Likely follow-ups

  • Where exactly does the key get generated, and why not on the server?
  • The user creates an order offline, then edits it, then goes online. What must your queue guarantee?
  • How long should the server retain idempotency keys, and what breaks when it forgets?
  • What happens if the response was a 500 - do you retry with the same key or a new one?
  • How would you test this without being able to reproduce process death reliably?

Related questions

Further reading