Activities and workflows can fail due to various intermediate conditions. In those cases, we want to retry the failed activity or child workflow or even the parent workflow. This can be achieved by supplying an optional retry policy. A retry policy looks like the following:
To enable retry, supply a custom retry policy to
when you execute them.
If activity heartbeat its progress before it failed, the retry attempt will contain the progress so activity implementation could resume from failed progress like:
Like retry for an activity, you need to supply a retry policy for
ChildWorkflowOptions to enable
retry for a child workflow. To enable retry for a parent workflow, supply a retry policy when
you start a workflow via
There are some subtle changes to workflow's history events when
RetryPolicy is used.
For an activity with
ActivityTaskScheduledEventwill have extended
ActivityTaskStartedEventwill not show up in history until the activity is completed or failed with no more retry. This is to avoid recording the
ActivityTaskStartedevent but later it failed and retried. Using the
DescribeWorkflowExecutionAPI will return the
PendingActivityInfoand it will contain
attemptCountif it is retrying.
For a workflow with
- If a workflow failed and needs to retry, the workflow execution will be closed with a
ContinueAsNewevent. The event will have the
RetryPolicyand the new
RunIdfor the next retry attempt.
- The new attempt will be created immediately. But the first decision task won't be scheduled until the backoff duration
which is also recorded in the new run's