Skip to content

Transaction issue after server inactivity (4.2.0.BUILD-SNAPSHOT) #373

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

Closed
tavolate opened this issue Nov 17, 2016 · 11 comments
Closed

Transaction issue after server inactivity (4.2.0.BUILD-SNAPSHOT) #373

tavolate opened this issue Nov 17, 2016 · 11 comments

Comments

@tavolate
Copy link

tavolate commented Nov 17, 2016

Neo4j server version: 3.0.7
Spring data neo4j: 4.2.0.M1
Neo4j ogm bolt driver: 2.0.5

Our web application is deployed on AWS Elastic beanstalk. It works well, but after a period of inactivity, the first request fails with this error

java.lang.NullPointerException at org.springframework.data.neo4j.transaction.Neo4jTransactionManager.doRollback(Neo4jTransactionManager.java:265) ~[spring-data-neo4j-4.2.0.M1.jar:?] at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:853) ~[spring-tx-4.3.0.RELEASE.jar:4.3.0.RELEASE] at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:830) ~[spring-tx-4.3.0.RELEASE.jar:4.3.0.RELEASE] at org.springframework.transaction.interceptor.TransactionAspectSupport.completeTransactionAfterThrowing(TransactionAspectSupport.java:503) ~[spring-tx-4.3.0.RELEASE.jar:4.3.0.RELEASE] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:285) ~[spring-tx-4.3.0.RELEASE.jar:4.3.0.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[spring-tx-4.3.0.RELEASE.jar:4.3.0.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.0.RELEASE.jar:4.3.0.RELEASE] at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) ~[spring-aop-4.3.0.RELEASE.jar:4.3.0.RELEASE]

Issuing the same request again succeeds.

@mangrish
Copy link
Contributor

@tavolate Can you try with SDN 4.2.0.BUILD-SNAPSHOT and OGM 2.1.0-SNAPSHOT. These are about to go GA soon so they are more developed and stable than M1 and 2.0.5

@tavolate
Copy link
Author

tavolate commented Nov 18, 2016

Neo4j server version: 3.0.7
Spring data neo4j: 4.2.0.BUILD-SNAPSHOT
Neo4j ogm bolt driver: 2.1.0-SNAPSHOT

@mangrish I updated the versions but we have the same error.

java.lang.NullPointerException at org.springframework.data.neo4j.transaction.Neo4jTransactionManager.doRollback(Neo4jTransactionManager.java:275) ~[spring-data-neo4j-4.2.0.BUILD-20161110.100915-135.jar:?] at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:853) ~[spring-tx-4.3.0.RELEASE.jar:4.3.0.RELEASE] at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:830) ~[spring-tx-4.3.0.RELEASE.jar:4.3.0.RELEASE] at org.springframework.transaction.interceptor.TransactionAspectSupport.completeTransactionAfterThrowing(TransactionAspectSupport.java:503) ~[spring-tx-4.3.0.RELEASE.jar:4.3.0.RELEASE] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:285) ~[spring-tx-4.3.0.RELEASE.jar:4.3.0.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[spring-tx-4.3.0.RELEASE.jar:4.3.0.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.0.RELEASE.jar:4.3.0.RELEASE] at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) ~[spring-aop-4.3.0.RELEASE.jar:4.3.0.RELEASE]

Below the spring framework transaction log

14:11:55 +00:00 ERROR [org.springframework.transaction.interceptor.TransactionInterceptor] Application exception overridden by rollback exception org.springframework.data.neo4j.exception.UncategorizedNeo4jException: Error executing Cypher; Code: N/A; Description: Unable to send messages to server: Connection timed out; nested exception is org.neo4j.ogm.exception.CypherException: Error executing Cypher; Code: N/A; Description: Unable to send messages to server: Connection timed out at org.springframework.data.neo4j.transaction.SessionFactoryUtils.convertOgmAccessException(SessionFactoryUtils.java:171) ~[spring-data-neo4j-4.2.0.BUILD-20161110.100915-135.jar:?] at org.springframework.data.neo4j.repository.support.SessionBeanDefinitionRegistrarPostProcessor.translateExceptionIfPossible(SessionBeanDefinitionRegistrarPostProcessor.java:71) ~[spring-data-neo4j-4.2.0.BUILD-20161110.100915-135.jar:?] at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59) ~[spring-tx-4.3.0.RELEASE.jar:4.3.0.RELEASE] at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213) ~[spring-tx-4.3.0.RELEASE.jar:4.3.0.RELEASE] at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147) ~[spring-tx-4.3.0.RELEASE.jar:4.3.0.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.0.RELEASE.jar:4.3.0.RELEASE] at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-4.3.0.RELEASE.jar:4.3.0.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.0.RELEASE.jar:4.3.0.RELEASE] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) ~[spring-aop-4.3.0.RELEASE.jar:4.3.0.RELEASE] Caused by: org.neo4j.driver.v1.exceptions.ClientException: Unable to send messages to server: Connection timed out at org.neo4j.driver.internal.connector.socket.SocketConnection.flush(SocketConnection.java:121) ~[neo4j-java-driver-1.0.5.jar:1.0.5-1ac0038a72f5592c9449ada24142828b2c5f2f1e] at org.neo4j.driver.internal.connector.ConcurrencyGuardingConnection.flush(ConcurrencyGuardingConnection.java:150) ~[neo4j-java-driver-1.0.5.jar:1.0.5-1ac0038a72f5592c9449ada24142828b2c5f2f1e] at org.neo4j.driver.internal.pool.PooledConnection.flush(PooledConnection.java:170) ~[neo4j-java-driver-1.0.5.jar:1.0.5-1ac0038a72f5592c9449ada24142828b2c5f2f1e] at org.neo4j.driver.internal.InternalTransaction.run(InternalTransaction.java:167) ~[neo4j-java-driver-1.0.5.jar:1.0.5-1ac0038a72f5592c9449ada24142828b2c5f2f1e] at org.neo4j.driver.internal.InternalTransaction.run(InternalTransaction.java:132) ~[neo4j-java-driver-1.0.5.jar:1.0.5-1ac0038a72f5592c9449ada24142828b2c5f2f1e] at org.neo4j.driver.internal.InternalTransaction.run(InternalTransaction.java:145) ~[neo4j-java-driver-1.0.5.jar:1.0.5-1ac0038a72f5592c9449ada24142828b2c5f2f1e] Caused by: java.io.IOException: Connection timed out at sun.nio.ch.FileDispatcherImpl.write0(Native Method) ~[?:1.8.0_101] at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) ~[?:1.8.0_101] at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) ~[?:1.8.0_101] at sun.nio.ch.IOUtil.write(IOUtil.java:65) ~[?:1.8.0_101] at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471) ~[?:1.8.0_101] at org.neo4j.driver.internal.connector.socket.TLSSocketChannel.wrap(TLSSocketChannel.java:282) ~[neo4j-java-driver-1.0.5.jar:1.0.5-1ac0038a72f5592c9449ada24142828b2c5f2f1e]

Below the OGM NEO4J log

14:11:55 +00:00 DEBUG [org.neo4j.ogm.session.Neo4jSession] Thread 30: beginTransaction() 14:11:55 +00:00 DEBUG [org.neo4j.ogm.session.Neo4jSession] Thread 30: Neo4jSession identity: org.neo4j.ogm.session.delegates.TransactionsDelegate@3f70d216 14:11:55 +00:00 DEBUG [org.neo4j.ogm.drivers.bolt.driver.BoltDriver] No current transaction, starting a new one 14:11:55 +00:00 DEBUG [org.neo4j.ogm.drivers.bolt.driver.BoltDriver] Native transaction: org.neo4j.driver.internal.InternalTransaction@5e716ecb 14:11:55 +00:00 DEBUG [org.neo4j.ogm.session.Neo4jSession] Thread 30: Transaction, tx id: org.neo4j.ogm.drivers.bolt.transaction.BoltTransaction@794e032c 14:11:55 +00:00 INFO [org.neo4j.ogm.drivers.bolt.request.BoltRequest] Request: MATCH (*******) RETURN u with params {0=************************} 14:11:55 +00:00 DEBUG [org.neo4j.ogm.drivers.bolt.transaction.BoltTransaction] Rolling back native transaction: org.neo4j.driver.internal.InternalTransaction@5e716ecb 14:11:55 +00:00 WARN [org.neo4j.ogm.drivers.bolt.transaction.BoltTransaction] Transaction is already closed 14:11:55 +00:00 DEBUG [org.neo4j.ogm.transaction.Transaction] Thread 30: Rollback transaction extent: 0 14:11:55 +00:00 DEBUG [org.neo4j.ogm.transaction.Transaction] Thread 30: Rolled back

According to this log seems that the transaction is already closed for some reason

@tavolate tavolate changed the title Transaction issue after server inactivity (4.2.0.M1) Transaction issue after server inactivity (4.2.0.BUILD-SNAPSHOT) Nov 18, 2016
@tavolate
Copy link
Author

With neo4j-java-driver 1.1.0-M06 we have this error

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 e xecuting 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.

@mangrish
Copy link
Contributor

@tavolate This error looks extremely unusual. Is AWS hibernating your Neo4j instance? See: neo4j/neo4j-java-driver#267. This looks like an issue with either AWS or the driver. I suggest you create a ticket on them and if you can provide some code that they can run on AWS to replicate (including the steps).

@tavolate
Copy link
Author

Thank you for your help. I investigate with the provider of the database service (graphene db) and I discovered that the free plan (sandbox) goes to sleep after a while. I think our issue is due to this behavior.

@mangrish
Copy link
Contributor

You might want to try the HTTP driver for your situation since it's stateless. The bolt driver might hold some state with it's protocol.

@tavolate
Copy link
Author

is the bolt protocol better than http? (I think so)

@mangrish
Copy link
Contributor

performance wise? yes. But it's also fairly new (as of Neo4j 3.x). I would recommend adding your case here as a ticket for them so it can be prioritised. In my opinion the driver should work still. Even after a reboot of the database.

@tavolate
Copy link
Author

yes I agree with you

@mangrish
Copy link
Contributor

@tavolate Have you raised a ticket with https://github.com/neo4j/neo4j-java-driver/issues? Is it ok to close this issue? I'm not sure we can do much more here.

@nandosola
Copy link

@mangrish could you please have a look at neo4j/neo4j-ogm#319 It seems that as long as neo4j-ogmthrows the right exception, spring-data-neo4j could reconnect?

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

No branches or pull requests

3 participants