agent timed out when airflow REST API hung on dag run status poll, poll failed
Gives agents a resilient pattern for polling the Airflow REST API: timeouts, backoff, and distinguishing API hangs from run problems. Use when status polls hang and the agent times out. Not for API errors that return fast.
TL;DR
The Airflow API hung instead of answering, so the agent's poll never returned: the webserver is overloaded, the metadata database is slow, or the request queued behind heavy UI traffic. Put a hard timeout on every poll, back off exponentially, and treat repeated hangs as an Airflow health problem, not a run problem. Never poll without a timeout.
agent timed out when airflow REST API hung on dag run status poll, poll failedUse this when
- Agent polls to the Airflow API hang instead of returning.
- The agent's own timeout fires on the poll, not on the run.
- Polls work sometimes and hang other times.
Not for this skill when
- The API returns errors quickly. Handle the error codes.
- The DAG run itself is stuck. Diagnose the run separately.
Steps
- Set an explicit timeout on every API poll, shorter than the agent's overall deadline. Note polls cannot hang forever. Verify: the hang is bounded
- Add exponential backoff with jitter between polls. Note poll pressure drops during outages. Verify: the agent stops adding load
- After consecutive hung polls, check Airflow health: webserver load, database latency. Note the health signal. Verify: API hangs become a health question
- Distinguish the two failures: API hung means unknown run state, not failed run. Note the distinction in the agent's reasoning. Verify: unknown is not failed
- Escalate Airflow health problems with the poll history attached. Note the escalation. Verify: the right team gets the right evidence
Variant phrasings
airflow api timeout polling
The API-shaped search.
airflow rest api slow dag run status
The symptom phrasing.
Compatibility: Airflow 2.x REST API. Timeout and backoff are client-side patterns, API-version independent.
Why it happens
The Airflow webserver serves the UI, the API, and sometimes heavy ad-hoc queries from the same process pool. When the metadata database slows down, API requests queue behind everything else and a status poll that should take milliseconds hangs for minutes. An agent polling without its own timeout inherits that hang and burns its deadline waiting for an answer about a run that might be perfectly healthy. The poll timeout is what keeps an API problem from becoming an agent problem.
Edge cases / pitfalls
- Treating a hung poll as a failed run is the classic misread. Unknown state needs re-polling, not failure handling.
- Aggressive polling during an Airflow slowdown makes the slowdown worse. Back off; the API is telling you it is busy by not answering.
- The experimental API and the stable API have different performance characteristics. Use the stable v1 API for polling.
- Auth token expiry mid-polling looks like hangs on some clients. Refresh credentials on a schedule, not just on 401s.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_ljkOnBSItLehK9sZMthgbw