Repository navigation
fix(db): a failed reconnect gives its lease back in the pools (#1306) - #1317
Merged
Merged
Conversation
…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.
3 tasks
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.
Closes #1306
Problem: in the PostgreSQL, MySQL and SQLite pools,
acquiredidentry.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 == 0is required) and never evicted, and enough of them exhausted the 32 slots (pool exhausted).Fix:
_ensureConnecteddoes 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.