0
votes

I currently have a pub/sub push subscription that pushes to a http endpoint. This endpoint then triggers my cloud function. I am running into an issue where the same events that have already been sent to my cloud function are being resent by the pub/sub subscription. I increased my subscription's ack deadline to 3 minutes but after about a minute into my cloud functions execution, it will resend the same event that has already been processed. This leads to multiple invocations of my cloud function and further issues. I haven't seen any way to disable pub/sub retries but wondering if there are any suggestions as to a root cause of this or any work arounds? Current set-up:

  • cloud function timeout limit: 120seconds
  • pub/sub subscription ack deadline: 180seconds
  • dead-lettering after 5 retries
1
Try returning a non-error response from your endpoint, like (for Node) res.json({ received: true }) to the caller.Aadmaa
doesn't matter with a pubsub, these are typically timed/scheduled tasksDIGI Byte

1 Answers

0
votes

You will need to consider idempotency and flag any recent retries to prevent them from firing again. This could be a timestamp stored in a database and filter based on time and any metadata you contain. Another important thing is to return a successful result.

Doug covers this concept in a video, while it doesn't reference pubsub, it is still just as valid: https://www.youtube.com/watch?v=Pwsy8XR7HNE