A startup uses Cloud Functions with a Pub/Sub trigger to process incoming orders. They notice that the function sometimes fails to process messages, and those messages are lost. What is the most likely cause?
Trap 1: The subscription has an ackDeadlineSeconds of 600.
High ack deadline is not a problem.
Trap 2: The Cloud Function has a timeout of 540 seconds.
Long timeout is fine.
Trap 3: The Pub/Sub topic has a retention duration of 10 minutes.
Even with short retention, messages are not lost if acknowledged quickly.
- A
The subscription has an ackDeadlineSeconds of 600.
Why it fails: High ack deadline is not a problem.
- B
The Cloud Function has a timeout of 540 seconds.
Why it fails: Long timeout is fine.
- C
The Pub/Sub topic has a retention duration of 10 minutes.
Why it fails: Even with short retention, messages are not lost if acknowledged quickly.
- D
The Cloud Function is configured with retry on failure set to false.
With retry on failure disabled, Pub/Sub acknowledges the message once the function invocation completes, even if it threw an error. No redelivery occurs, so failed orders are discarded rather than retried, explaining the message loss described in the stem.