neo4j / neo4j-ogm

Java Object-Graph Mapping Library for Neo4j
https://neo4j.com/docs/ogm-manual/
Apache License 2.0
337 stars 165 forks source link

Neo4j-ogm configuration doesn't expose same parameters as native driver configuration connection reset by peer with Bolt driver in HA Mode. #358

Closed janagamap closed 7 years ago

janagamap commented 7 years ago

Native Java bolt driver exposes additional properties compared to Neo4j-ogm Configuration class.
Issue only occurs for bolt driver.

org.neo4j.driver.v1.Config final Config config = Config .build() .withMaxIdleSessions(30) .withLogging(new JULogging(Level.INFO)) .withRoutingFailureLimit(3) .withConnectionLivenessCheckTimeout(300, TimeUnit.SECONDS) .toConfig(); Exposes .withConnectionLivenessCheckTimeout(300, TimeUnit.SECONDS) and .withRoutingFailureLimit(3)

neo4j-ogm/api/src/main/java/org/neo4j/ogm/config/Configuration.java doesnt expose the same properties as native Driver config.

With High Availability Cluster with haproxy as the front end or F5 as the front end load balancer, the native driver doesn't throw connection reset by peer error.

With Spring data neo4j-ogm combination, the connection reset by peer error is seen intermittently.

Expected Behavior

Expected Behavior is to not get the error and the configuration should be similar to the Native driver.

Current Behavior

Stack trace which is thrown:

aused by: org.neo4j.driver.v1.exceptions.ServiceUnavailableException: Unable to send messages to server: Connection reset by peer at org.neo4j.driver.internal.net.SocketConnection.flush(SocketConnection.java:167) at org.neo4j.driver.internal.net.SocketConnection.sync(SocketConnection.java:152) at org.neo4j.driver.internal.net.ConcurrencyGuardingConnection.sync(ConcurrencyGuardingConnection.java:137) at org.neo4j.driver.internal.net.pooling.PooledSocketConnection.sync(PooledSocketConnection.java:157) at org.neo4j.driver.internal.ExplicitTransaction.runBeginStatement(ExplicitTransaction.java:262) at org.neo4j.driver.internal.ExplicitTransaction.(ExplicitTransaction.java:83) at org.neo4j.driver.internal.NetworkSession.beginTransaction(NetworkSession.java:297) at org.neo4j.driver.internal.NetworkSession.beginTransaction(NetworkSession.java:174) at org.neo4j.driver.internal.NetworkSession.beginTransaction(NetworkSession.java:181) at org.neo4j.ogm.drivers.bolt.driver.BoltDriver.nativeTransaction(BoltDriver.java:117) at org.neo4j.ogm.drivers.bolt.driver.BoltDriver.newTransaction(BoltDriver.java:74) at org.neo4j.ogm.session.transaction.DefaultTransactionManager.openTransaction(DefaultTransactionManager.java:71) at org.neo4j.ogm.session.transaction.DefaultTransactionManager.openTransaction(DefaultTransactionManager.java:57) at org.neo4j.ogm.drivers.bolt.request.BoltRequest.executeRequest(BoltRequest.java:153) ... 60 common frames omitted Caused by: java.io.IOException: Connection reset by peer at sun.nio.ch.FileDispatcherImpl.write0(Native Method) at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) at sun.nio.ch.IOUtil.write(IOUtil.java:65) at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471) at org.neo4j.driver.internal.net.ChunkedOutput.flush(ChunkedOutput.java:62) at org.neo4j.driver.internal.packstream.PackStream$Packer.flush(PackStream.java:162) at org.neo4j.driver.internal.messaging.PackStreamMessageFormatV1$Writer.flush(PackStreamMessageFormatV1.java:337) at org.neo4j.driver.internal.messaging.PackStreamMessageFormatV1$Writer.flush(PackStreamMessageFormatV1.java:101) at org.neo4j.driver.internal.net.SocketClient.send(SocketClient.java:161) at org.neo4j.driver.internal.net.SocketConnection.flush(SocketConnection.java:163) ... 73 common frames omitted

Possible Solution

Steps to Reproduce (for bugs)

  1. ...
  2. ...
  3. ...
  4. ...

Context

Your Environment

nmervaillie commented 7 years ago

The connection check has been added in the commit referenced above.

Discussed with the neo4j driver team : this should be enough for good support of firewalls / load balancers. Didn't add the routing failure limit as it is now deprecated in recent driver versions.

Leaving that issue open for now because it has not yet been done in master/3.x. We need to figure out how to best manage this, possibly by allowing a driver instance to be passed to the session factory at init.