Neo4J 4.0.2 driver exceptions: NOT PART OF CHAIN! RelationshipTraversalCursor and DynamicRecord not in use

Hello,

I am upgrading a Java project from Java 8 (1.8.0_222) + Neo4J driver version 1.3.1 to Java 11.0.2 + Neo4J driver version 4.0.2. When making the necessary changes, I encountered an issue that I didn’t have before.

I’m using futures to compute score values for a list of nodes within a custom procedure. This scoring operation requires fetching the nodes’ relationships and neighbors from the database multiple times within the callable method. At different points in time throughout the procedure’s test, I receive the two errors attached below. This causes some futures to fail, returning fewer results than expected.

The code that generates these errors works just fine with Java 8 + Neo4J driver version 1.3.1. Also, when using Java 11.0.2 + Neo4J driver version 4.0.2, the score computation gives the expected results as well, but only when called synchronously, without using futures. When called asynchronously, it generates unexpected behavior, often causing the test to fail with different output results.

I am running the code on a handmade 20-node test database and I’m not performing any inserts, updates, or deletes, so I can rule out the possibility of corrupted data. Synchronous calls aren’t an option as these results need to be obtained quickly.

If anyone knows what could generate this problem and what I can do to solve it, please let me know.

The two stack traces encountered are:

NOT PART OF CHAIN! RelationshipTraversalCursor[id=18, open state with: denseNode=false, next=18, mode=regular, underlying record=Relationship[18,used=true,source=13,target=4,type=2,sCount=2,sNext=17,tPrev=16,tNext=39,prop=174,secondaryUnitId=-1, sFirst,!tFirst]]
java.lang.IllegalStateException: NOT PART OF CHAIN! RelationshipTraversalCursor[id=18, open state with: denseNode=false, next=18, mode=regular, underlying record=Relationship[18,used=true,source=13,target=4,type=2,sCount=2,sNext=17,tPrev=16,tNext=39,prop=174,secondaryUnitId=-1, sFirst,!tFirst]]
    at org.neo4j.internal.recordstorage.RecordRelationshipTraversalCursor.computeNext(RecordRelationshipTraversalCursor.java:287)
    at org.neo4j.internal.recordstorage.RecordRelationshipTraversalCursor.next(RecordRelationshipTraversalCursor.java:176)
    at org.neo4j.kernel.impl.newapi.DefaultRelationshipTraversalCursor.next(DefaultRelationshipTraversalCursor.java:189)
    at org.neo4j.internal.kernel.api.helpers.RelationshipSparseSelection.fetchNext(RelationshipSparseSelection.java:135)
    at org.neo4j.internal.kernel.api.helpers.RelationshipSparseSelectionIterator.hasNext(RelationshipSparseSelectionIterator.java:47)
    at recommendations.helpers.CustomerInterface.getCustomerOrderedProducts(CustomerInterface.java:108)
    at recommendations.helpers.CategoryWorker.getSimilarProducts(CategoryWorker.java:276)
    at recommendations.helpers.CategoryWorker.call(CategoryWorker.java:78)
    at recommendations.helpers.CategoryWorker.call(CategoryWorker.java:15)
    at java.base/java.util.concurrent.FutureTask.run$$capture(FutureTask.java:264)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
org.neo4j.driver.exceptions.ClientException: Failed to invoke procedure `rec.relevantCategories`: Caused by: recommendations.exceptions.DatabaseRuntimeException: org.neo4j.kernel.impl.store.InvalidRecordException: DynamicRecord[1048576,used=false,(0),type=-1,data=byte[],start=true,next=-1] not in use

    at org.neo4j.driver.internal.util.Futures.blockingGet(Futures.java:143)
    at org.neo4j.driver.internal.InternalResult.blockingGet(InternalResult.java:128)
    at org.neo4j.driver.internal.InternalResult.list(InternalResult.java:105)
    at recommendations.RelevantCategoriesTest.testCategoryFilter(RelevantCategoriesTest.java:64)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
    at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
    at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.neo4j.harness.junit.rule.Neo4jRule$1.evaluate(Neo4jRule.java:89)
    at org.junit.rules.RunRules.evaluate(RunRules.java:20)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
    Suppressed: org.neo4j.driver.internal.util.ErrorUtil$InternalExceptionCause
        at org.neo4j.driver.internal.util.ErrorUtil.newNeo4jError(ErrorUtil.java:80)
        at org.neo4j.driver.internal.async.inbound.InboundMessageDispatcher.handleFailureMessage(InboundMessageDispatcher.java:105)
        at org.neo4j.driver.internal.messaging.v1.MessageReaderV1.unpackFailureMessage(MessageReaderV1.java:83)
        at org.neo4j.driver.internal.messaging.v1.MessageReaderV1.read(MessageReaderV1.java:59)
        at org.neo4j.driver.internal.async.inbound.InboundMessageHandler.channelRead0(InboundMessageHandler.java:83)
        at org.neo4j.driver.internal.async.inbound.InboundMessageHandler.channelRead0(InboundMessageHandler.java:35)
        at org.neo4j.driver.internal.shaded.io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99)
        at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
        at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
        at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)
        at org.neo4j.driver.internal.async.inbound.MessageDecoder.channelRead(MessageDecoder.java:47)
        at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
        at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
        at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)
        at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
        at org.neo4j.driver.internal.shaded.io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
        at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at org.neo4j.driver.internal.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at org.neo4j.driver.internal.shaded.io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
        at org.neo4j.driver.internal.shaded.io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
        at org.neo4j.driver.internal.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714)
        at org.neo4j.driver.internal.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
        at org.neo4j.driver.internal.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
        at org.neo4j.driver.internal.shaded.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
        at org.neo4j.driver.internal.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
        at org.neo4j.driver.internal.shaded.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at org.neo4j.driver.internal.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:834)
1 Like