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
fix(db): a failed reconnect leaks a pool lease, and slots are never released #1306
In the three pools, acquire increments the entry's refs and then awaits the reconnect of a dropped connection:
entry.refs++;
if (!entry.connection.isConnected) await_reconnect(entry, mode);
returnPgLease._(this, entry, entry.connection);
lib/core/database/postgres_connection_pool.dart:101 and :134
lib/core/database/mysql_connection_pool.dart:89 and :122
lib/core/database/sqlite_connection_pool.dart:93 and :127
When the reconnect throws (server restarted, network down), no lease is returned, so nobody releases it and refs stays raised. The entry is never idle-disposed (refs == 0 is required) and never evicted by _evictIfNeededBeforeNewSlot. Repeated failures across databases / modes fill the 32 slots with unevictable entries, and every later acquire fails with StateError: ... pool exhausted.
Scope
Decrement refs (and re-arm the idle timer) when the reconnect fails, in all three pools; or take the lease only after the connection is usable.
Test with a fake connection whose connect fails: after N failed acquires the pool can still evict and create entries.
Acceptance
A failed reconnect leaves refs as before the call.
After a failed reconnect the entry is idle-disposed after the delay.
maxEntries failed acquires do not exhaust the pool.
Activity
Merge pull request #1317 from QueryaHub/fix/1306-pool-lease-leak
ZhuchkaTriplesix commentedon Oct 10, 2026
Сделано в #1317, смержено в dev.