Skip to content

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

Merged
pierrejeambrun merged 1 commit into
v3-3-testfrom
backport-0807f2b-v3-3-test
Aug 27, 2026
Merged

pierrejeambrun merged 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 [email protected]
Co-authored-by: Claude Fable 5 [email protected]

…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 <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>
@pierrejeambrun

Copy link
Copy Markdown
Member

Unrelated CI failure merging.

@pierrejeambrun
pierrejeambrun merged commit 3c43d12 into v3-3-test Aug 27, 2026
148 of 186 checks passed
@pierrejeambrun
pierrejeambrun deleted the backport-0807f2b-v3-3-test branch August 27, 2026 10:15
@github-actions github-actions Bot added this to the Airflow 3.3.2 milestone Aug 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor Author

Hi maintainer, this PR was merged without a milestone set.
We've automatically set the milestone to Airflow 3.3.2 based on: merged to version branch
If this milestone is not correct, please update it to the appropriate milestone.

This comment was generated by Milestone Tag Assistant.

vatsrahul1001 pushed a commit that referenced this pull request Sep 7, 2026
…g-run terminal state (#71488) (#71955)

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 <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>
@vatsrahul1001 vatsrahul1001 added the type:bug-fix Changelog: Bug Fixes label Sep 8, 2026
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 type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants