Skip to content

Reduce event-loop stalls when reading task states - #42

Open
Dev-iL wants to merge 3 commits into
DataDog:zach.gottesman/async-get-ti-statesfrom
Dev-iL:async-ti-states-streaming
Open

Dev-iL wants to merge 3 commits into
DataDog:zach.gottesman/async-get-ti-statesfrom
Dev-iL:async-ti-states-streaming

Conversation

@Dev-iL

@Dev-iL Dev-iL commented Oct 3, 2026

Copy link
Copy Markdown

Stream task-state results in partitions of 500 to reduce event-loop stalls when the async /task-instances/states endpoint handles large runs. Build the response by unpacking rows and assigning states directly, and skip the Dag-wide query when a task group is requested without explicit task IDs.

The streamed result is closed before fetching task-group states, including on cancellation or failure. Response fields, mapped-task keys, and the existing task/task-group selection semantics are preserved.

Implements the follow-up proposed in the review comment on apache/airflow#73966. This PR targets DataDog:zach.gottesman/async-get-ti-states.

Validation: ruff and ruff-format prek hooks passed. Tests, benchmarks, and full Breeze hooks were not run for this PR, as requested. Performance measurements in the linked comment predate this PR; streaming uses a server-side cursor inside the request transaction, and PgBouncer compatibility was not verified.


Was generative AI tooling used to co-author this PR?
  • Yes — Codex (GPT-6)

Generated-by: Codex (GPT-6) following the guidelines

zach-overflow and others added 3 commits October 1, 2026 11:13
Task-group lookups can decompress and deserialize serialized Dags and
initialize operator links. This work must stay off the API event loop
when database reads use an async session.
The async states route ran ORM entity hydration for every matching task
instance and its eagerly joined Dag run on the API event loop, stalling
other requests on large mapped runs. Only four columns are consumed.

Per-developer agent instruction files must never be committed.
Large async state responses still hold the event loop while processing all rows at once. Follow the review recommendation to keep it available during large requests.
@zach-overflow
zach-overflow force-pushed the zach.gottesman/async-get-ti-states branch 2 times, most recently from be60f19 to 66be871 Compare October 5, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants