google-cloud-platformgoogle-cloud-functionsgoogle-cloud-pubsubdead-letter

GCP Pub/Sub does more retries than configured


I have a Pub/Sub push subscription that is triggering Cloud Function. There is retry policy with expotential backoff and dead lettering enabled.

Configuration is next:

For testing purposes I configured Cloud Function to always return 500 error code. But instead of 5 retries and 1 event in dead letter topic there was:

I can assume that dead letter topic received more events because there was more retries than expected. But I cannot understand why there was more retries than configured?


Solution

  • Pub/Sub has a built in At-least-once delivery system which will retry messages that were not acknowledged. In this case, after 600s have passed, the message you first sent becomes unacknowledged, thus Pub/Sub retries the message. It will keep retrying it for 600s until it reaches the messageRetentionDuration or you acknowledge it.