Solution skill
Diagnose: Pub/Sub duplicates and DEADLINE_EXCEEDED on subscribers
Complete solution
Shows how to fix diagnose: Pub/Sub duplicates and DEADLINE_EXCEEDED on subscribers. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Set flow control (max outstanding messages) so slow handlers do not pile up redeliveries. Add a dead-letter topic with maxdeliveryattempts.
Steps
- Symptom: the same message delivered multiple times while the handler is still running it, or gRPC DEADLINE_EXCEEDED on the subscriber.
- Cause: ack deadline (default 10s) expired before ack. Pub/Sub redelivered. Your handler is fine; its lease is too short.
- Confirm:
- Check the subscription ack deadline:
gcloud pubsub subscriptions describe [SUB]. - Measure handler time: log start/end per message_id. If p99 exceeds the ack deadline, diagnosis confirmed.
- Check Monitoring for redelivery counts spiking alongside slow handlers.
- Fix:
- Raise the ack deadline to cover p99 with headroom:
gcloud pubsub subscriptions update [SUB] --ack-deadline [SECONDS](max 600). - Prefer the streaming-pull client library, which extends leases while the handler runs. Manual pull loops never extend.
- Set flow control (max outstanding messages) so slow handlers do not pile up redeliveries.
- Add a dead-letter topic with maxdeliveryattempts. One poison message that always exceeds the deadline will otherwise redeliver forever.
- Do not set 600s blindly for every subscription. Long deadlines delay redelivery of genuinely failed messages. Match the deadline to the handler.
- Make handlers idempotent regardless: dedupe on message_id. At-least-once means duplicates are always possible, even with perfect tuning.
- Verify: redelivery count in Monitoring drops to near zero after the change, and each message_id is processed once in your logs.
When to use
You are seeing this: Symptom: the same message delivered multiple times while the handler is still running it, or gRPC DEADLINEEXCEEDED on the subscriber. Use this skill when you run into "Diagnose: Pub/Sub duplicates and DEADLINEEXCEEDED on subscribers".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
Verified 2026-09-26 on the Pub/Sub troubleshooting docs (DEADLINE_EXCEEDED, timeout behavior) and subscriber docs (ack deadline range, flow control, dead-letter policy).
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_zEFhElngGpdzEXOi3co76Q" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Diagnose: Pub/Sub duplicates and DEADLINE_EXCEEDED on subscribers <span>— Vectle</span></a>