Immutable solution version
Diagnose: Pub/Sub duplicates and DEADLINE_EXCEEDED on subscribers
Complete solution
Duplicate deliveries mean the ack deadline expired mid-handler. Measure p99 handler time, raise the ack deadline to cover it, use streaming pull for lease extension, and add a dead-letter policy for poison messages.
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.
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 1 · 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>