Skip to content

[v3-3-test] Reuse the ambient session when skipping pending TIs in dag-run terminal state (#71488) - #71955

Draft
github-actions[bot] wants to merge 1 commit into
v3-3-testfrom
backport-0807f2b-v3-3-test
Draft

[v3-3-test] Reuse the ambient session when skipping pending TIs in dag-run terminal state (#71488)#71955
github-actions[bot] wants to merge 1 commit into
v3-3-testfrom
backport-0807f2b-v3-3-test

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

TaskInstance.set_state is @provide_session: called without a session,
every pending task instance gets its own session — a fresh DB
connection (with the documented sql_alchemy_pool_enabled=False +
pgbouncer setup), a refresh SELECT, a merge SELECT, an UPDATE and a
COMMIT. Marking a dag run failed on a run with 3,917 mapped task
instances took 280 s (~19,500 statements, ~3,900 connections) on an
otherwise idle PostgreSQL 17 with 2.5 ms RTT.

Passing the ambient session through drops the per-TI cost from 79 ms
to 7.5 ms measured on the same run (x10.5); the dag-run state and the
running-TI path already use this session, so transactional semantics
are unchanged.
(cherry picked from commit 0807f2b)

Co-authored-by: Mat matthieuauger@users.noreply.github.com
Co-authored-by: Claude Fable 5 noreply@anthropic.com

…g-run terminal state (#71488)

TaskInstance.set_state is @provide_session: called without a session,
every pending task instance gets its own session — a fresh DB
connection (with the documented sql_alchemy_pool_enabled=False +
pgbouncer setup), a refresh SELECT, a merge SELECT, an UPDATE and a
COMMIT. Marking a dag run failed on a run with 3,917 mapped task
instances took 280 s (~19,500 statements, ~3,900 connections) on an
otherwise idle PostgreSQL 17 with 2.5 ms RTT.

Passing the ambient session through drops the per-TI cost from 79 ms
to 7.5 ms measured on the same run (x10.5); the dag-run state and the
running-TI path already use this session, so transactional semantics
are unchanged.
(cherry picked from commit 0807f2b)

Co-authored-by: Mat <matthieuauger@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant