Skip to content

Conversation

@lutovich
Copy link
Contributor

It was previously spread between RoutingSession, RoutingTransaction and RoutingStatementResult and they all did the same thing when connection errors happened.

This PR introduces RoutingPooledConnection that handles errors for routing driver by removing entries from the routing table and purging connection pool for failed address.

It was previously spread between `RoutingSession`, `RoutingTransaction` and
`RoutingStatementResult` and they all did the same thing when connection
errors happened.

This commit introduces `RoutingPooledConnection` that handles errors for
routing driver by removing entries from the routing table and purging
connection pool for failed address.
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.

+1

// In the future, we might be able to move this logic to the server.
switch ( accessMode )
{
case READ:
Copy link
Contributor

Choose a reason for hiding this comment

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

We actually do not need this READ/WRITE mode as the error itself already self explained:

Neo.ClientError.Cluster.NotALeader -> server at xx no longer accepts writes
Neo.ClientError.General.ForbiddenOnReadOnlyDatabase -> Write queries cannot be performed in READ access mode

So we could totally remove access mode from this class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is possible to get NotALeader when trying to write in a read session with connection towards follower and ForbiddenOnReadOnlyDatabase when connection is towards read replica. So it looks like we still need this switch on the access mode.


public interface PooledConnection extends Connection
{
long lastUsedTimestamp();
Copy link
Contributor

Choose a reason for hiding this comment

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

We should also move
onError
hasUnrecoverableErrors
from Connection to PooledConnection


private static boolean isFailureToWrite( ClientException e )
{
return e.code().equals( "Neo.ClientError.Cluster.NotALeader" ) ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Warning: you might get ClientException without code field at this stage :)

Methods `#onError()` and `#hasUnrecoverableErrors()` are only useful in pooled
connection and their implementations threw exceptions in regular connection.
This commit moves them to `PooledConnection` interface.
@lutovich
Copy link
Contributor Author

@zhenlineo comments should be addressed now

@zhenlineo zhenlineo merged commit 9d6c2fd into neo4j:1.2 Feb 21, 2017
@lutovich lutovich deleted the 1.2-err-handling-in-conn branch February 21, 2017 12:45
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