Skip to content

fix(db): a failed reconnect gives its lease back in the pools (#1306) - #1317

Merged
ZhuchkaTriplesix merged 1 commit into
devfrom
fix/1306-pool-lease-leak
Oct 10, 2026
Merged

ZhuchkaTriplesix merged 1 commit into
devfrom
fix/1306-pool-lease-leak

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Closes #1306

Problem: in the PostgreSQL, MySQL and SQLite pools, acquire did entry.refs++ and then awaited the reconnect of a dropped entry. When the reconnect threw (server restarted, network down), no lease was returned to the caller, so nothing released the count. The entry was then never idle-disposed (refs == 0 is required) and never evicted, and enough of them exhausted the 32 slots (pool exhausted).

Fix: _ensureConnected does the reconnect and, when it fails, releases the count before rethrowing. The two acquire paths (existing entry, new entry) of each pool use it. Callers sharing one in-flight reconnect each give back their own count.

Tests (each pool): after a failed reconnect the entry is still idle-disposed once the original lease is released; with maxEntries: 2, two failed reconnects leave both slots evictable and a third key acquires.

…ySQL and SQLite pools (#1306)

acquire counted the lease before reconnecting a dropped entry. When the
reconnect threw, nobody held the lease to release it, so the entry
stayed in use for good: never idle-disposed, never evicted, and a few of
them filled the pool with pool exhausted errors.

The count is now given back when the reconnect fails.
@github-actions github-actions Bot added bug Something isn't working stability Theme parser epic label: stability core Core library logic and services connections Database connections, URI parsing, pools P1 High priority / Core capability labels Oct 10, 2026
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit 2d1b7c3 into dev Oct 10, 2026
15 checks passed
@ZhuchkaTriplesix
ZhuchkaTriplesix deleted the fix/1306-pool-lease-leak branch October 11, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working connections Database connections, URI parsing, pools core Core library logic and services P1 High priority / Core capability stability Theme parser epic label: stability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant