Skip to content

Couple fixes for release of broken connections to the pool #368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 8, 2018

Conversation

lutovich
Copy link
Contributor

@lutovich lutovich commented May 3, 2018

Fixes #304

lutovich added 2 commits May 3, 2018 15:25
An attempt to resolve a pending acquisition request can be made when
connection is returned back to the pool. It will only be made when
there exists a pending acquisition request and returned connection
is valid.

It was previously possible for the release operation to deque a pending
acquisition request and forget about it, even when the returned
connection was invalid. This made the acquisition request either
fail with acquisition timeout or with "Cannot read property 'filter'
of undefined" error. Later happened because subsequent release operation
for the same key removed the array of pending acquisition requests.

This commit fixes the problem by making release operation only deque an
acquisition request when new request can be acquired.
Release operation discards the connection if it is broken. It also tries
to resolve a pending acquisition request, if any. In order to this it
tries to execute a promise-free internal acquire that immediately
returns an available resource or creates a new one, if possible. New
resource can only be created if pool is not at its maximum capacity.

Previously, release operation only decremented the active connection
counter at the end. This made it impossible to create a new connection
when broken one is returned.

This commit fixes the problem by making `Pool#_release()` decrement
the active counter after connection has been either added to the list
of idle connections or discarded because it turned out to be broken.
@lutovich lutovich requested a review from ali-ince May 3, 2018 13:58
@ali-ince ali-ince merged commit 0ebdcca into neo4j:1.6 May 8, 2018
@lutovich lutovich deleted the 1.6-filter-in-pool branch May 8, 2018 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants