Skip to content

Improve disposal of broken connections #387

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 11 commits into from
Jul 10, 2017

Conversation

lutovich
Copy link
Contributor

@lutovich lutovich commented Jul 7, 2017

Connection pool can discard broken connections during acquisition (when connection liveness check timeout is configured) and when connections are returned to the pool. In both cases connections should be disposed and removed from the set of active connections. This is especially important with least connected load balancing strategy which examines amount of active connections for each address.

This PR makes sure broken connections are disposed through the connections queue to make sure active set is always updated.

Based on #386, only last commit is new.

lutovich added 11 commits July 4, 2017 18:04
Round-robin load balancing was previously coupled with the address
set implementation and made it hard to use different load balancing
algorithm.

This commit turns RoundRobinAddressSet into a simple concurrent set of
addresses and moves load balancing logic into a separate component that
takes list of available addresses and returns one that should be used
next. This allows easier implementation of new load balancing
algorithms. Rediscovery procedure will now not use load balancing and
query routers in a known order (which is randomized by the database).
This replaces the existing round-robin. It gives us better performance
with clusters composed of different machine capacities.
Lease connected load balancing strategy selects start index in
round-robin fashion to avoid always selecting same machine when cluster
does not have any running transactions or
all machines have same number of active connections.
And removed unused test events based infrastructure.
Connection pool can discard broken connections during acquisition
(when connection liveness check timeout is configured) and when
connections are returned to the pool. In both cases connections
should be disposed and removed from the set of active connections.
This is especially important with least connected load balancing
strategy which examines amount of active connections for each address.

This commit makes sure broken connections are disposed through the
connections queue to make sure active set is always updated.
@lutovich lutovich requested a review from zhenlineo July 7, 2017 09:28
Copy link
Contributor

@zhenlineo zhenlineo left a comment

Choose a reason for hiding this comment

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

Looks good.

createLoadBalancingStrategy( config, connectionPool ) );
}

private LoadBalancingStrategy createLoadBalancingStrategy( Config config, ConnectionPool connectionPool )
Copy link
Contributor

Choose a reason for hiding this comment

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

Method can be static

* @param message the warning message
* @param cause the cause of the warning
*/
void warn( String message, Throwable cause );
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a API change that will probably break user's code. Just saying...

@zhenlineo zhenlineo merged commit a9ed77e into neo4j:1.5 Jul 10, 2017
@lutovich lutovich deleted the 1.5-close-broken-idle-conns branch July 10, 2017 08:46
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