From 79f5b5c53bf1e404e834e9ed8b889a34436ab79f Mon Sep 17 00:00:00 2001 From: Jonas Calvi Meinerz Date: Wed, 18 Oct 2023 13:36:21 +0100 Subject: [PATCH] Explain exceptions inside each_iteration --- guides/iteration-how-it-works.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/guides/iteration-how-it-works.md b/guides/iteration-how-it-works.md index ac86df3a..f8ae8442 100644 --- a/guides/iteration-how-it-works.md +++ b/guides/iteration-how-it-works.md @@ -20,6 +20,11 @@ SELECT `products`.* FROM `products` ORDER BY products.id LIMIT 100 ```sql SELECT `products`.* FROM `products` WHERE (products.id > 2) ORDER BY products.id LIMIT 100 ``` +## Exceptions inside `each_iteration` + +When an unrescued exception happens inside the `each_iteration` block, the job will stop and re-enqueue itself with the last successful cursor. This means that the iteration that failed will be retried with the same parameters and the cursor will only move if that iteration succeeds. This behaviour may be enough for intermittent errors, such as network connection failures, but if your execution is deterministic and you have an error, subsequent iterations will never run. + +In other words, if you are trying to process 100 records but you have a problem with the 61st, only the first 60 will be processed. ## Signals