Fix async engine missing pool_recycle and pool_pre_ping configuration#65276
Open
kaxil wants to merge 1 commit intoapache:mainfrom
Open
Fix async engine missing pool_recycle and pool_pre_ping configuration#65276kaxil wants to merge 1 commit intoapache:mainfrom
pool_recycle and pool_pre_ping configuration#65276kaxil wants to merge 1 commit intoapache:mainfrom
Conversation
Member
pierrejeambrun
left a comment
There was a problem hiding this comment.
Thanks for the PR!
Just one comment
822ad26 to
8df1808
Compare
kaxil
commented
Apr 15, 2026
8df1808 to
0e78bfa
Compare
The async SQLAlchemy engine was created without any pool health settings while the sync engine got pool_size, pool_recycle, pool_pre_ping, and max_overflow from [database] config. This meant dead connections from PostgreSQL idle timeouts or pgbouncer disconnects were never detected by the async pool. Read the same [database] config values for the async engine. Also respect SQL_ALCHEMY_POOL_ENABLED=False by using NullPool, matching the sync engine behavior.
0e78bfa to
1c730ac
Compare
pierrejeambrun
approved these changes
Apr 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The async SQLAlchemy engine was created with zero pool configuration while the sync engine got pool_size, pool_recycle, pool_pre_ping, and max_overflow from [database] config.
How this is hit
The async engine serves all Execution API requests that go through async session dependencies. The API server (gunicorn) creates the async engine at startup via _configure_async_session(). Without pool health settings:
The sync engine has had these settings since day one. The async engine missed them when _configure_async_session() was extracted from configure_orm() in PR #51920.
Fix
Read the same [database] config section values (pool_size, pool_recycle, pool_pre_ping, max_overflow) for the async engine. Also respect SQL_ALCHEMY_POOL_ENABLED=False by using NullPool, matching the sync engine behavior for pgbouncer setups that require it.
The create_async_metadata_engine() signature gains an optional engine_args parameter (defaulting to None for backward compatibility with existing airflow_local_settings.py overrides). Upstream PR should update the cluster-policies.rst docs to show the new signature.