3

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:

  • Acknowledge deadline is 60s
  • Exactly once delivery enabled
  • Maximum delivery attempts is 5
  • Miniumn backoff - 30s, maximum backoff - 600s

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:

  • 6 retries and 2 events in dead letter topic
  • 7 retries and 3 events in dead letter topic
  • 10 retries and 6 events in dead letter topic

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?

  • @myhailoroman if you consider the answer above has solved your question please consider [accepting it](https://meta.stackexchange.com/q/5234/179419) by clicking the check-mark. This indicates to the wider community that you've found a solution and gives some reputation to both the answerer and yourself. There is no obligation to do this. – Hector Martinez Rodriguez May 12 '22 at 00:29

1 Answers1

0

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.

Eduardo Ortiz
  • 715
  • 3
  • 14
  • 1
    Yes, I know. But I have configured dead lettering which should limit retries to 5 attempts. But insted I was receiving messages with deliveryAttempt:5, deliveryAttempt":6, deliveryAttempt":7, etc. I am supposing that it's an issue with "exactly once delivery". This feature is in preview mode so might be buggy. Once I turned it off and set retry policy to "Retry immidiately" it started working as expected. – Mykhailo Roman May 03 '22 at 11:26
  • As you mention, it might be because the feature is in a preview mode and might be causing issues with your code, so my recommendation for you is that you turn it off so you can make it work as it should. – Eduardo Ortiz May 03 '22 at 13:18