I'm using Google Cloud Tasks and Cloud Functions together to execute a lot of tasks in parallel.
maxAttempts
= 10.It seems to work well most of the time, but I've seen an unexpected behavior happen a few times: sometimes, Cloud Tasks thinks that the function failed and retries it, even though the function hadn't finished running yet, and eventually succeeded. When that happens, I see this in the queue's logs (the queue was created with --log-sampling-ratio=1.0
):
So the Cloud Function ended up executing with success 2 times.
I know that Cloud Tasks can't guarantee strict only-once execution at all times, as stated in the documentation. However, I'd still like to confirm if this particular occurrence is expected and whether there is any way to prevent it.
Define in your task:
tasksClient.createTask({ parent: queuePath, task, resource: { retryConfig: { maxAttempts: 1 } } })
I found it here: doc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With