Cloud Tasks Duplicate Execution: Make the Report Handler Safe to Retry

A Cloud Tasks worker must tolerate the same job arriving again. Put the business job key in a durable ledger, coordinate concurrent handlers, and return success only after the report outcome is durably known. A queue task name or a successful enqueue request does not establish that the report was produced.

Define one business operation

For a fictional Korean branch report, use branch:Seoul|date:2026-11-23|revision:1 as the business key. Validate the payload before beginning work. Separate that key from transport attempt IDs, so re-enqueuing the same business request does not create another report.

Google documents that duplicate executions can occur and that queue order is not guaranteed.[1] Do not depend on “revision 1 will run before revision 2.” Either make revisions independent or enforce version prerequisites in your own application.

Coordinate handlers with durable state

Use storage that can enforce a unique business key and transactional state transitions. In one transaction, inspect the job and claim an eligible attempt. A completed job can return its recorded outcome. Another active attempt should remain pending rather than launch the same work.

A simple “read, then insert” check without concurrency control can race. If you use leases, include an ownership token and require state updates to match it; expiry alone does not stop the old worker from continuing. An expired claim with a possibly completed external operation belongs in reconciliation.

These are design requirements, not features Cloud Tasks adds to your database.

Guard the external side effect

For a report destination, prefer a documented idempotent create mechanism or destination identifier that can be reconciled. Persist that identifier before calling the destination. After a timeout, inspect the destination using it before trying again.

If the downstream operation has neither a reliable lookup nor idempotency support, mark the outcome UNKNOWN and alert an operator. A ledger cannot make an arbitrary external send exactly once. For example, blindly resending an email after a connection failure can produce two messages.

Persist the verified final report reference and mark the job DONE before acknowledging delivery. Cloud Tasks treats HTTP 200–299 as success; other responses or no response invoke its retry behavior.[2] If you hand off work asynchronously, acknowledge only after a durable handoff with its own monitored completion mechanism—not after starting an in-memory thread.

Test recovery and access controls

Authenticate the worker endpoint using the documented approach; task headers alone are not proof of identity.[3] Use fictional branch data and no production credentials in fixtures.

Test simultaneous duplicate deliveries, a crash before the destination call, a timeout after destination success, ledger failure before DONE, and a retry after DONE. Also test claim expiry with an old worker still running. The acceptance result is one reconciled business outcome and a visible recovery path—not merely two HTTP requests returning green.

Diagram showing a task delivery checked against a durable job ledger before a completion response, with uncertain side effects routed to reconciliation.
Original explanatory diagram: reconcile uncertain side effects before acknowledging a report task. This is not a product screenshot. AI-assisted editorial illustration.

Official sources and claim mapping

Documentation checked: November 23, 2026 (KST). Each source below was successfully retrieved and read for the listed claims. No inaccessible source is marked verified. Documentation review verifies the described product behavior; it does not establish that this workflow was executed.

  1. Google Cloud — Issues and limitations — Claims supported: Duplicate executions can occur and queue execution order is not guaranteed.
  2. Google Cloud — REST tasks resource — Claims supported: HTTP 200–299 acknowledges a task; other responses or missing responses trigger configured retry behavior.
  3. Google Cloud — Create HTTP target tasks — Claims supported: Task headers are informational, not identity proof; handler authentication guidance.

Recommended ledger fields, state names, example identifiers, acceptance criteria, and recovery policies are the author’s operating design, not claims that the vendor supplies these features automatically. No plan entitlement, price, legal compliance, or performance guarantee is asserted.

Explore more:
Previous guide
Next guide