Skip to content

[v3-2-test] Prevent Session leak from StreamingResponse API endpoints#65193

Merged
vatsrahul1001 merged 1 commit intov3-2-testfrom
backport-65162
Apr 14, 2026
Merged

[v3-2-test] Prevent Session leak from StreamingResponse API endpoints#65193
vatsrahul1001 merged 1 commit intov3-2-testfrom
backport-65162

Conversation

@vatsrahul1001
Copy link
Copy Markdown
Contributor

Backport of #65162

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

The comment in the test sums up what was going on, but essentially this result
in `session.close` being called when the endpoint returned, but before the
response was generated.

Then SQLA was 'helpful' and re-opened it. However since the
teardown/post-yield code has already run, this new session is never closed.

This results in a connection open that leaks untli Python's full GC runs (i.e.
`gc.collect()`) -- it going out of scope doesn't delete things as the
Session and the RootTransaction form a cycle.

(cherry picked from commit 5559365)
@vatsrahul1001 vatsrahul1001 changed the base branch from main to v3-2-test April 14, 2026 07:30
@vatsrahul1001 vatsrahul1001 removed the backport-to-v3-2-test Mark PR with this label to backport to v3-2-test branch label Apr 14, 2026
@vatsrahul1001 vatsrahul1001 added area:API Airflow's REST/HTTP API and removed area:dev-tools area:registry area:production-image Production image improvements and fixes labels Apr 14, 2026
@vatsrahul1001 vatsrahul1001 added this to the Airflow 3.2.1 milestone Apr 14, 2026
@vatsrahul1001 vatsrahul1001 merged commit 2c6ed8e into v3-2-test Apr 14, 2026
3 checks passed
@vatsrahul1001 vatsrahul1001 deleted the backport-65162 branch April 14, 2026 07:47
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.

3 participants