Skip to content

Commit d878bef

Browse files
authored
Document how retry policies and durable execution work together (#73160)
1 parent 9611649 commit d878bef

3 files changed

Lines changed: 49 additions & 0 deletions

File tree

‎airflow-core/docs/core-concepts/resumable-tasks.rst‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,42 @@ Comparison
226226
- Airflow 2.2
227227
- Airflow 3.3
228228
- Airflow 3.2
229+
230+
.. _concepts-resumable-tasks-retry-policies:
231+
232+
Retry policies and durable execution
233+
------------------------------------
234+
235+
Long-running tasks typically need two separate things together: a retry
236+
policy, and durable execution as defined above. Each is configurable per
237+
task, and together they let a workflow span days without losing progress.
238+
239+
A **retry policy** decides whether a failed attempt gets another try, and
240+
how long to wait before it. This is :class:`~airflow.sdk.RetryPolicy` and
241+
:class:`~airflow.sdk.RetryDecision` (see :ref:`concepts:retry-policies`), or
242+
the LLM-driven
243+
:class:`~airflow.providers.common.ai.policies.retry.LLMRetryPolicy`, which
244+
uses a model to read the error and make that call. That policy adds its own
245+
``fallback_rules``, applied when the classification call itself fails, so
246+
the decision does not depend on the model being reachable (see
247+
:doc:`apache-airflow-providers-common-ai:retry_policies`).
248+
249+
**Durable execution** is what that next attempt resumes from. Backed by the
250+
task state store described above, it is what lets a task recover a
251+
checkpoint written by the attempt before it, rather than starting over.
252+
253+
Long-running tasks, or LLM-driven tasks like agentic workflows, benefit
254+
most from both: the retry policy decides whether the error is worth
255+
retrying at all, and the task state store is what the retry resumes from.
256+
257+
Consider using both when a task:
258+
259+
* Runs long enough that a worker crash mid-run is a real risk, and
260+
* Needs a retry decision more nuanced than "always retry" or "never
261+
retry", for example retrying rate limits but failing outright on bad
262+
credentials.
263+
264+
The two operate independently. A task with ``retries=5`` and a checkpoint
265+
still stops for good after six failed attempts (the initial attempt plus five
266+
retries), but each of those retries picks up from the last checkpoint instead of
267+
reprocessing files it already finished, or resubmitting a job that is still running.

‎airflow-core/docs/core-concepts/tasks.rst‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,14 @@ DAG was triggered:
314314
return RetryDecision.fail(reason="Backfill run -- not retrying")
315315
return RetryDecision.default()
316316
317+
A retry policy only decides whether and when a task gets another attempt. It
318+
receives the full run ``context``, so it can inspect checkpointed progress
319+
through ``context["task_state_store"]`` when making that decision, but it
320+
never persists or restores that progress itself -- resuming from a checkpoint
321+
is the task's own work. For a task that also needs to resume from where it
322+
left off, pair a retry policy with the task state store described in
323+
:ref:`concepts-resumable-tasks-retry-policies`.
324+
317325
.. _concepts:task-instance-heartbeat-timeout:
318326

319327
Task Instance Heartbeat Timeout

‎providers/common/ai/docs/retry_policies.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ retry decisions. It works with any LLM provider supported by pydantic-ai
2626
(OpenAI, Anthropic, Bedrock, Vertex, Ollama, etc.).
2727

2828
For the core retry policy concepts, see :doc:`apache-airflow:core-concepts/tasks`.
29+
If the task also needs to survive a worker crash without losing its progress,
30+
see :ref:`apache-airflow:concepts-resumable-tasks-retry-policies`.
2931

3032
Setup
3133
-----

0 commit comments

Comments
 (0)