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

Handle ServiceUnavailableException from the Java Bolt Driver #319

Closed
nandosola opened this issue Jan 10, 2017 · 6 comments
Closed

Handle ServiceUnavailableException from the Java Bolt Driver #319

nandosola opened this issue Jan 10, 2017 · 6 comments
Assignees

Comments

@nandosola
Copy link

nandosola commented Jan 10, 2017

Hi,

As per neo4j/neo4j-java-driver#302, the Java Driver is launching ServiceUnavailableException in case the client loses connection with the server (eg. network glitches, server restarts, …). AFAIK the philosophy is that the libs and apps using the driver should catch ServiceUnavailableException.

However, I noticed that neo4j-ogm does not handle ServiceUnavailableException yet. The only reference to a server disconnection I've found is ClientException being rethrown as a CypherException:

It seems that CypherException is too generic. For instance, spring-data-neo4j handles it this way:

org.springframework.data.neo4j.exception.UncategorizedNeo4jException: Error executing Cypher; 
  Code: N/A; Description: SSL Connection terminated while receiving data. 
  This can happen due to network instabilities, or due to restarts of the database.; 

nested exception is org.neo4j.ogm.exception.CypherException: Error executing Cypher; 
  Code: N/A; Description: SSL Connection terminated while receiving data. 
  This can happen due to network instabilities, or due to restarts of the database.

So they don't have the information that a ServiceUnavailableException conveys, which for spring-data-neo4j could mean converting it to a RecoverableDataAccessException so that the connection could be retried (see: spring-projects/spring-data-neo4j#373)

In my (maybe naïve) debugging session, I've found that a possible solution could be creating a org.neo4j.ogm.exception.ServiceCommunicationException that can be used by the upper layers (eg. spring-data-neo4j). But where should the exception be launched?

Well, it seems that both BoltRequest.java and BoltResponse.java don't check for stale sessions:

transactionManager.getCurrentTransaction() == null

Wouldn't be enough, since the connection is stalled (hence not null) and the failure happens only after the request is executed or the results are fetched.

@nandosola nandosola changed the title Handle ServiceUnavailableException from the Java Driver Handle ServiceUnavailableException from the Java Bolt Driver Jan 10, 2017
@mangrish
Copy link
Contributor

Related to #301.

I think we should try to add this fix to the 2.1.2 release but it would be nice if we can sneak it in to 2.1.1.

@obriensystems
Copy link

I get this error only when running against the bolt port of an embedded instance (out and back in) using the java driver
When I run the same code on a server-mode instance it works fine

@ikwattro
Copy link

This exception will only be thrown from a neo4j 3.1 + instance btw using Bolt.

@nsteenv
Copy link

nsteenv commented May 2, 2017

Same issue here, trying to connect to an embedded instance with Bolt and java driver, any hint on how to do that?

@chrisbetz
Copy link

Hi. Having a similar issue: this happens to me only on Java 9, not on Java 8. Any hints on this?

@michael-simons
Copy link
Collaborator

Thanks for your feedback.

The Bolt transport will now translate this into org.neo4j.ogm.exception.ConnectionException. We plan on further refining in this area as well.

Regarding running embedded and opening a bolt port to the outside: We strongly recommend not doing this. Neo4j-OGM uses the database api to communicate with the embedded instance, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants