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 issue with connection pool deactivation #463

Merged
merged 2 commits into from
Jan 25, 2018

Conversation

lutovich
Copy link
Contributor

@lutovich lutovich commented Jan 22, 2018

Previously load balancer moved connection pool to deactivated state when corresponding cluster member had a network error. This was made to disallow any new connections towards that member. Member has also been removed from the routing table, so that callers never try to acquire connection from a deactivated pool. Deactivated pools were re-activated during rediscovery.

However, there was a case when deactivated pool towards the seed router would remain deactivated forever without a chance to be re-activated. It happened when connections to all cores failed and driver had to perform rediscovery using seed router. In this case all connections pools were deactivated, and rediscovery was not able to complete because it failed trying to obtain connection from a deactivated pool.

This PR fixes the problem by removing pool activation/deactivation. Instead driver will simply make instance non-routable by removing it's address from the routing table. Corresponding connection pool will not be changed. Later rediscovery will cleanup pools for non-routable addresses that have no active connections.

Same connection error handling logic is in 1.5. Only tests should be merged forward.

Previously load balancer moved connection pool to deactivated state when
corresponding cluster member had a network error. This was made to
disallow any new connections towards that member. Member has also been
removed from the routing table, so that callers never try to acquire
connection from a deactivated pool. Deactivated pools were
re-activated during rediscovery.

However, there was a case when deactivated pool towards the seed router
would remain deactivated forever without a chance to be re-activated.
It happened when connections to all cores failed and driver had to
perform rediscovery using seed router. In this case all connections
pools were deactivated, and rediscovery was not able to complete
because it failed trying to obtain connection from a deactivated pool.

This commit fixes the problem by removing pool activation/deactivation.
Instead driver will simply make instance non-routable by removing it's
address from the routing table. Corresponding connection pool will not
be changed. Later rediscovery will cleanup pools for non-routable
addresses that have no active connections.
@lutovich lutovich force-pushed the 1.4-fix-deactivated-pool branch from 07d4c0c to f024d8b Compare January 23, 2018 12:40
@@ -372,6 +372,8 @@ private HandshakeStatus wrap( ByteBuffer buffer ) throws IOException, ClientExce
cipherOut.compact();
}
break;
case CLOSED:
Copy link
Contributor

Choose a reason for hiding this comment

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

Just wonder why this is needed? Is it a fix to something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added stress test closes all connections to simulate them breaking. Without this branch closing might result in ClientException, which is not retriable. It feels better to have it as IOException so that it bubbles up to users as ServiceUnavailableException or SessionExpiredException. Does this sound sensible?

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.

👍

@lutovich lutovich merged commit 8c72e38 into neo4j:1.4 Jan 25, 2018
@lutovich lutovich deleted the 1.4-fix-deactivated-pool branch January 25, 2018 09:39
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.

3 participants