Reputation: 77
This can be considered a follow-up question to Invoking the same activity inside a loop in cadence workflow: How does the workflow recover in case of activity iteration ? Will is continue invoking the i-th activity (skipping the ones that were already invoked) or start again from 0 ? If so, how can the workflow be written so that activities that were invoked (0-'k') are skipped ?
Upvotes: 2
Views: 1056
Reputation: 196
First of all, it's important to understand the difference between workflow worker vs activity worker.
Coming back to your question: When your "workflow" worker crashes, restarts, lost or somehow a worker received a decision task that it doesn't know about its workflow; it will then request the history of that workflow from Cadence servers. It will replay the workflow until is consumes the whole history it receives then will schedule the next activity based on current local variables.
So it will continue from the same loop iteration with the same local variables and parameters to the activity.
Hope this answers your question
Upvotes: 3
Reputation: 41
My understanding is those iterations are replayed when the history is retrieved in the rescuing worker.
So iteration 1 had result 'x', iteration 2 had 'y' until it reaches the last activity that it hadn't recorded a result for, and then starts actually invoking the activities.
In this way, you can be sure the state of the workflow, and its potential variables, is exactly how it was when it terminated.
So they aren't exactly 'skipped' but they also don't re-execute.
If you don't want to replay hundreds of no-op iterations after a failure, you could consider using "continueAsNew" instead of a loop. This ensures the new workflow doesn't accrue the history of the other failed iterations.
Upvotes: 1
Reputation: 14896
Each activity invocation has its own retry policy, so if activity i fails, only activity i will be retried.
Upvotes: 0