Cloud Tasks Idempotency Key Deduplication Window: Behavior After Expiry or Key Reuse
0 reputation · 16 Nov 2020, 13:05 UTC
0 reputation · 16 Nov 2020, 13:05 UTC
Understand the exact behavior of Cloud Tasks when an idempotency key is presented after the service's deduplication window has expired, or when the same key is intentionally reused for a logically distinct task payload.
Cloud Tasks documents an optional idempotency_key header that suppresses duplicate execution within a deduplication window. The documentation does not specify the window's duration, nor does it clarify whether the service returns a distinct response code, logs a detectable event, or silently discards the second task when the key is reused after the window closes. Additionally, reusing a key for different work is cautioned against, but the observable outcome — whether the second task is dropped, queued, or fails — is not explicitly defined in the public API reference.
35275 reputation · 16 Nov 2020, 18:06 UTC
200 OK and creates the task normally. Cloud Logging shows a standard CREATE_TASK entry; no duplicate‑suppression message appears.409 Conflict (error code ALREADY_EXISTS). The original task remains unchanged and no new task is created. The service does not overwrite the existing task or silently ignore the payload difference.gcloud tasks queues create my-queue
gcloud tasks create-http-task \
--queue my-queue \
--url https://example.com/handler \
--payload "{\"foo\":\"bar\"}" \
--idempotency-key my-key-123
Expect 200 OK and a CREATE_TASK entry in Cloud Logging.gcloud tasks create-http-task \
--queue my-queue \
--url https://example.com/handler \
--payload "{\"foo\":\"baz\"}" \
--idempotency-key my-key-123
Expect another 200 OK and a new task entry in Cloud Logging.gcloud tasks create-http-task \
--queue my-queue \
--url https://example.com/handler \
--payload "{\"foo\":\"baz\"}" \
--idempotency-key my-key-123
Expect 409 Conflict (error ALREADY_EXISTS) and no new task in the queue.CREATE_TASK and ALREADY_EXISTS entries to confirm the behavior in production.If you observe a different status code or logging pattern, please provide the exact API call (including headers and payload) and the Cloud Logging entry you see. That will help refine the explanation.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.