Skip to content
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

Fixed timeout when acquiring connection from pool #313

Merged
merged 1 commit into from
Dec 22, 2017

Conversation

lutovich
Copy link
Contributor

Connection pool has limited size and returns Promise<Connection> instead of Connection directly. Returned promise can be failed when connection acquisition timeout has fired. Pool uses helper function util#promiseOrTimeout() to race acquisition and timeout promises.

This function allowed both timeout callback to be invoked and connection to be acquired. It cleared the timeout outside of the raced promises. As result connection was acquired but timeout callback failed in background. It tried to clear non-existing pending acquisition attempts.

This PR fixes the problem by including #clearTimeout() call in the chain of raced promises.

Fixes #304

Connection pool has limited size and returns `Promise<Connection>`
instead of `Connection` directly. Returned promise can be failed when
connection acquisition timeout has fired. Pool uses helper function
`util#promiseOrTimeout()` to race acquisition and timeout promises.

This function allowed both timeout callback to be invoked and connection
to be acquired. It cleared the timeout outside of the raced promises. As
result connection was acquired but timeout callback failed in background.
It tried to clear non-existing pending acquisition attempts.

This commit fixes the problem by including `#clearTimeout()` call in
the chain of raced promises.
@lutovich lutovich requested a review from ali-ince December 18, 2017 11:37
Copy link
Contributor

@ali-ince ali-ince left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ali-ince ali-ince merged commit b011bc1 into neo4j:1.5 Dec 22, 2017
@lutovich lutovich deleted the 1.5-pool-fix branch December 22, 2017 13:04
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