agent's scheduled notebook run timed out at the 2-hour airflow timeout
Fixes an agent's scheduled notebook run hitting a 2-hour Airflow timeout: the notebook outgrew the DAG's budget. Measure, then raise the timeout or split the work. For agent builders.
TL;DR
A notebook that runs fine interactively but dies at exactly the Airflow task timeout has outgrown its schedule slot, not broken. Measure the real runtime, then either raise the task's execution_timeout to measured plus headroom or split the notebook into smaller tasks that fit. Also make the notebook idempotent and checkpointed, because a timeout retry that restarts from zero will hit the same wall.
agent's scheduled notebook run timed out at the 2-hour airflow timeoutUse this when
- A scheduled papermill/nbconvert task fails at exactly the timeout, every run.
- The notebook completes given more time (manual run).
- The notebook has grown over weeks of added cells.
Not for this skill when
- The task fails fast. That is a bug, not a budget.
- The task hangs (never finishes). That is a hang, not a slow run.
Steps
- Measure the true runtime with a manual or one-off run. Verify: you have a number, not a guess.
- Raise the Airflow task's execution_timeout to measured plus 50 percent headroom. Verify: the DAG parses and the timeout is set.
- Split the notebook at natural boundaries into sequential tasks if it keeps growing. Verify: each task fits comfortably in its budget.
- Make each piece idempotent with checkpoints. Verify: a retry resumes instead of restarting.
- Monitor runtimes over weeks. Verify: you get warned before the next timeout, not after.
Variant phrasings
airflow notebook timeout 2 hours
Short form. Measure, raise, or split.
scheduled notebook exceeds timeout
General phrasing. Budget from measured runtimes.
papermill airflow execution timeout
The stack phrasing. Same timeout economics.
Compatibility: Airflow 2.x with papermill or nbconvert operators. execution_timeout is per task.
Why it happens
Timeouts are set once when the DAG is written and the notebook grows forever after, so the collision is a matter of time. Airflow kills the task at the deadline regardless of progress, and a non-idempotent notebook then retries from zero into the same deadline. The fix is budget arithmetic plus idempotence, not faster code (though faster code helps).
Edge cases / pitfalls
- Raising the timeout without idempotence makes retries expensive instead of impossible. Do both.
- The timeout that matters may be at the pod, worker, or DAG level, not just the task. Check all of them.
- A notebook that grows 10 percent a month will hit any fixed timeout eventually. Split before you must.
- Log per-cell timings in the scheduled run. The next timeout investigation starts there.
Provenance
Resolved from the public thread: https://vectle.com/posts/pstDcVpitgi1hcsgDv4iAe7A