cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Phase 1: replicate users.

When using APOC with Java driver, DeadlockDetectedException is hidden

chris8
Node

Hello, I use Java driver 4.4.7 with APOC to batch insertion of nodes and relations.

The problem is when a DeadlockDetectedException is thrown, the Back off strategy does not retry the transaction because the caught exception type is org.neo4j.driver.exceptions.ClientException (instead of org.neo4j.driver.exceptions.TransientException that would allow the retry)

Is this a bug ? Do I have to handle the retry myself ?

Here is the stack :

Could not execute UNWIND $batch AS row MATCH (a {id: row.source}) WHERE a:Node MATCH (b {id: row.target}) WHERE b:Node OPTIONAL MATCH (a)-[r {id: row.id}]->(b) CALL apoc.do.when( r IS NOT NULL, " CALL apoc.merge.relationship(a, row.type, {id: row.id}, {}, b, {}) YIELD rel SET rel = {}, rel.id = row.id WITH * CALL apoc.merge.relationship(a, row.type, {id: row.id}, row.properties, b, row.properties) YIELD rel as relation RETURN relation", "CALL apoc.merge.relationship(a, row.type, {id: row.id}, row.properties, b, row.properties) YIELD rel return rel", {row:row, a:a, b:b}) YIELD value RETURN count(value) AS nb
org.neo4j.driver.exceptions.ClientException: Failed to invoke procedure `apoc.do.when`: Caused by: org.neo4j.kernel.DeadlockDetectedException: ForsetiClient[transactionId=82065, clientId=7] can't acquire ExclusiveLock{owner=ForsetiClient[transactionId=82055, clientId=8]} on NODE(4152), because holders of that lock are waiting for ForsetiClient[transactionId=82065, clientId=7].
Wait list:ExclusiveLock[
Client[82055] waits for [ForsetiClient[transactionId=82065, clientId=7]]]
at org.neo4j.driver.internal.util.Futures.blockingGet(Futures.java:111) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.InternalResult.blockingGet(InternalResult.java:107) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.InternalResult.single(InternalResult.java:67) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at com.b4s.graphindex.graphstore.neo4j.Neo4JConnector.lambda$0(Neo4JConnector.java:92) ~[classes/:?]
at org.neo4j.driver.internal.InternalSession.lambda$transaction$4(InternalSession.java:137) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.retry.ExponentialBackoffRetryLogic.retry(ExponentialBackoffRetryLogic.java:106) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.InternalSession.transaction(InternalSession.java:134) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.InternalSession.writeTransaction(InternalSession.java:113) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.InternalSession.writeTransaction(InternalSession.java:108) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at com.b4s.graphindex.graphstore.neo4j.Neo4JConnector.writeBatch(Neo4JConnector.java:91) ~[classes/:?]
at com.b4s.graphindex.graphstore.neo4j.Neo4JGraphService.postRelations(Neo4JGraphService.java:325) ~[classes/:?]
at com.b4s.graphindex.graphstore.neo4j.Neo4JGraphService.postGraph(Neo4JGraphService.java:293) ~[classes/:?]
at com.b4s.graphindex.graphstore.neo4j.EmbeddedNeo4jTest.postNodes(EmbeddedNeo4jTest.java:519) ~[test-classes/:?]
at com.b4s.graphindex.graphstore.neo4j.EmbeddedNeo4jTest.lambda$9(EmbeddedNeo4jTest.java:456) ~[test-classes/:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[?:?]
at java.lang.Thread.run(Thread.java:829) ~[?:?]
Suppressed: org.neo4j.driver.internal.util.ErrorUtil$InternalExceptionCause
at org.neo4j.driver.internal.util.ErrorUtil.newNeo4jError(ErrorUtil.java:76) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.async.inbound.InboundMessageDispatcher.handleFailureMessage(InboundMessageDispatcher.java:107) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.messaging.common.CommonMessageReader.unpackFailureMessage(CommonMessageReader.java:75) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.messaging.common.CommonMessageReader.read(CommonMessageReader.java:53) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.async.inbound.InboundMessageHandler.channelRead0(InboundMessageHandler.java:81) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.async.inbound.InboundMessageHandler.channelRead0(InboundMessageHandler.java:37) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:327) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:299) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.async.inbound.MessageDecoder.channelRead(MessageDecoder.java:42) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:327) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:299) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at org.neo4j.driver.internal.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[neo4j-java-driver-4.4.7.jar:4.4.7-3c0b9ab64a2ee57abc45be64d9e39a5df78df9b7]
at java.lang.Thread.run(Thread.java:829) ~[?:?]
1 REPLY 1

chris8
Node

The problem occurs only with Neo4j enterprise version and not with community version