You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Airflow 3.2.0 opens too many meta DB connections #65010
** Issue Description **
After upgrading from Airflow 3.1.8 to 3.2.0 without changing the configuration we encountered the problem that the meta database (running on PostgreSQL) stops accepting connections. Or, if we increase the allowed connections on the database, the sql achemy pool fills up.
The sql_alchemy settings are the default ones:
sql_alchemy_pool_enabled = True
sql_alchemy_pool_size = 5
sql_alchemy_max_overflow = 10
The allowed parallel database connections on the postgresql is set to 100.
We have 1x api server, 1 x scheduler, 1 x triggerer.
Increasing the sql_alchemy pool and the postgresql connections does not solve the issue - it just takes more time until the connection pool is filled up or the database stops accepting connections.
It looks like the database connections are not properly closed and left open. Over time the connections sum up.
What you think should happen instead?
All database connections should be closed when they are no longer needed.
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
Hi, I noticed something similar, we just upgraded a couple hours ago.
Even with pgbouncer in front of the postgres db, api will fail after a certain time.
We have 2 api and 2 scheduler, 1 triggerer, 3 workers.
Hi, same experience with the upgrade from 3.1.8 to 3.2.0. We tried on Monday but our test suite was able to replicate this problem in about two hours. We reset everything and tried again, and at around ~2hrs we had DB connection issues that failed all of the jobs in flight. It looked like it recovered on its own if given enough time ~10 min but we had to rollback to 3.1.8. We use pgbouncer, as well.
To help narrow down the root cause, could you capture some PostgreSQL diagnostics next time the issue occurs?
1. Connection state snapshot (most important -- run when connections are high):
SELECT state, count(*) AS cnt
FROM pg_stat_activity
WHERE datname = current_database()
GROUP BY state
ORDER BY cnt DESC;
And the detailed view:
SELECT state, wait_event_type, wait_event,
left(query, 100) AS query_prefix,
age(now(), query_start) AS duration
FROM pg_stat_activity
WHERE datname = current_database()
ORDER BY query_start;
This tells us whether the stuck connections are active, idle, or idle in transaction.
2. Lock contention -- are connections waiting on each other?
SELECTblocked.pid, left(blocked.query, 80) AS blocked_query,
blocking.pidAS blocking_pid, left(blocking.query, 80) AS blocking_query
FROM pg_stat_activity blocked
JOIN pg_locks bl ONbl.pid=blocked.pidAND NOT bl.grantedJOIN pg_locks gl ONgl.locktype=bl.locktypeANDgl.relation=bl.relationANDgl.grantedJOIN pg_stat_activity blocking ONblocking.pid=gl.pidWHEREblocked.datname= current_database();
3. Log table size -- the log table gets an INSERT on every task state change (new in 3.2.0). If it's large, INSERTs slow down and hold connections longer:
SELECT relname, n_live_tup, n_dead_tup,
pg_size_pretty(pg_total_relation_size(oid)) AS total_size,
last_autovacuum
FROM pg_stat_user_tables
WHERE relname ='log';
4. Connection growth trend -- run every 5 minutes for ~30 minutes to capture the accumulation pattern:
SELECT now(), count(*), state
FROM pg_stat_activity
WHERE datname = current_database()
GROUP BY state;
5. PostgreSQL timeout settings:
SHOW idle_in_transaction_session_timeout;
SHOW tcp_keepalives_idle;
The state column from is the single most useful data point. If we see growing idle in transaction connections, that's a session leak. If we see active connections piling up on INSERT INTO log or SELECT ... FOR UPDATE, that's lock contention from new 3.2.0 query patterns.
Hi, I had similar issues when upgrading to versions 3.1.2 and 3.1.3. I can't guarantee this will solve your issue(s). I solved mine by doing the following:
Fixing my SSL issue. I would recommend checking the logging in your webserver log file, that's where I found my issues.
Changing the file parsing sort mode if you are using mnt on your containers. It seems like parsing multiplies connections, but unfortunately I haven't found out why. I have changed my file_parsing_sort_mode to alphabetical.
Hi @kaxil ,
I have gathered the output required, have a look here below.
I'm available to dig deeper.
app=> SELECT state, count(*) AS cnt
FROM pg_stat_activity
WHERE datname = current_database()
GROUP BY state
ORDER BY cnt DESC;
state | cnt
--------+-----
idle | 20
active | 1
(2 rows)
app=> SELECT blocked.pid, left(blocked.query, 80) AS blocked_query,
blocking.pid AS blocking_pid, left(blocking.query, 80) AS blocking_query
FROM pg_stat_activity blocked
JOIN pg_locks bl ON bl.pid = blocked.pid AND NOT bl.granted
JOIN pg_locks gl ON gl.locktype = bl.locktype AND gl.relation = bl.relation AND gl.granted
JOIN pg_stat_activity blocking ON blocking.pid = gl.pid
WHERE blocked.datname = current_database();
pid | blocked_query | blocking_pid | blocking_query
-----+---------------+--------------+----------------
(0 rows)
We use cnpg with posgres 18, oids are not enabled by default
app=> SELECT relname, n_live_tup, n_dead_tup,
pg_size_pretty(pg_total_relation_size(oid)) AS total_size,
last_autovacuum
FROM pg_stat_user_tables
WHERE relname = 'log';
ERROR: column "oid" does not exist
LINE 2: pg_size_pretty(pg_total_relation_size(oid)) AS total_...
app=> SELECT now(), count(*), state
FROM pg_stat_activity
WHERE datname = current_database()
GROUP BY state;
now | count | state
-------------------------------+-------+--------
2026-04-13 08:48:38.289699+00 | 1 | active
2026-04-13 08:48:38.289699+00 | 20 | idle
(2 rows)
app=> SHOW idle_in_transaction_session_timeout;
SHOW tcp_keepalives_idle;
idle_in_transaction_session_timeout
-------------------------------------
0
(1 row)
tcp_keepalives_idle
---------------------
7200
(1 row)
I run the queries directly on the db, not through pgbouncer
What is unusual is the behaviour when job gets queued.
This morning we added a batch of around 200 jobs, using a pool of 20 slots
The db showed this behaviour here, which was not present before
Activity
boring-cyborg commentedon Apr 10, 2026
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
alessandro-peyrachia-rnc commentedon Apr 10, 2026
Hi, I noticed something similar, we just upgraded a couple hours ago.
Even with pgbouncer in front of the postgres db, api will fail after a certain time.
We have 2 api and 2 scheduler, 1 triggerer, 3 workers.
pgbouncer set at
Affects mainly the api service
dclfan commentedon Apr 10, 2026
Hi, same experience with the upgrade from 3.1.8 to 3.2.0. We tried on Monday but our test suite was able to replicate this problem in about two hours. We reset everything and tried again, and at around ~2hrs we had DB connection issues that failed all of the jobs in flight. It looked like it recovered on its own if given enough time ~10 min but we had to rollback to 3.1.8. We use pgbouncer, as well.
pgbouncer settings
pool_mode = transaction max_client_conn = 1000 default_pool_size = 20 max_db_connections = 75kaxil commentedon Apr 11, 2026
To help narrow down the root cause, could you capture some PostgreSQL diagnostics next time the issue occurs?
1. Connection state snapshot (most important -- run when connections are high):
And the detailed view:
This tells us whether the stuck connections are
active,idle, oridle in transaction.2. Lock contention -- are connections waiting on each other?
3. Log table size -- the
logtable gets an INSERT on every task state change (new in 3.2.0). If it's large, INSERTs slow down and hold connections longer:4. Connection growth trend -- run every 5 minutes for ~30 minutes to capture the accumulation pattern:
5. PostgreSQL timeout settings:
The
statecolumn from is the single most useful data point. If we see growingidle in transactionconnections, that's a session leak. If we seeactiveconnections piling up onINSERT INTO logorSELECT ... FOR UPDATE, that's lock contention from new 3.2.0 query patterns.dedalozzo commentedon Apr 12, 2026
potiuk commentedon Apr 13, 2026
amarbrkic commentedon Apr 13, 2026
Hi, I had similar issues when upgrading to versions 3.1.2 and 3.1.3. I can't guarantee this will solve your issue(s). I solved mine by doing the following:
mnton your containers. It seems like parsing multiplies connections, but unfortunately I haven't found out why. I have changed my file_parsing_sort_mode to alphabetical.LengYue12389 commentedon Apr 13, 2026
Hi, I seem to have encountered the problem of running out of connection pool, and I haven't found the cause yet

alessandro-peyrachia-rnc commentedon Apr 13, 2026
Hi @kaxil ,
I have gathered the output required, have a look here below.
I'm available to dig deeper.
We use cnpg with posgres 18, oids are not enabled by default
I run the queries directly on the db, not through pgbouncer
What is unusual is the behaviour when job gets queued.
This morning we added a batch of around 200 jobs, using a pool of 20 slots
The db showed this behaviour here, which was not present before
Let me know how can I help further,
Thanks
ashb commentedon Apr 13, 2026
I think I've managed to reproduce this locally.
Investigating.
6 remaining items
ashb commentedon Apr 13, 2026
PR and unit tests to follow shortly, and then we can start a vote for 3.2.1
ashb commentedon Apr 13, 2026
My fix def gets most of the occurrences. It sounds like Jed could have another case.
rbayer666 commentedon Apr 14, 2026
Wow, thank you all for your effort!
potiuk commentedon Apr 14, 2026
Also for posterity - #65179 follow up that would avoid holding the connection too long (resource hog).
Release DB connection before deserializing DAGs in grid structure end…
Release DB connection before deserializing DAGs in grid structure end…
[v3-3-test] Release DB connection before deserializing DAGs in grid s…
[v3-3-test] Release DB connection before deserializing DAGs in grid s…
[v3-3-test] Release DB connection before deserializing DAGs in grid s…