cancel
Showing results for 
Search instead for 
Did you mean: 

Error when restoring a backup with cypher-shell

rogelio_basurto
Node Link

Hello everybody!
I hope you all well!

Today, I was trying to restore a backup in my local computer (dev) from the dev environment. So first, I did the backup with the following line:

CALL apoc.export.cypher.all('backup.cypher',{format:'cypher-shell', useOptimizations: {type: "UNWIND_BATCH", unwindBatchSize: 20}})

Then in my local computer, I open the powershell (yeah, Win10) and went to the project folder and typed:

type .\import\backup.cypher | .\bin\cypher-shell.bat  -u neo4j -p password -d database_name --format plain

And obtained the next error:
An error occurred while in an open transaction. The transaction will be rolled back and terminated. Error: Tried to execute Schema modification after executing Write query
After running with --debug, I get the following error:

org.neo4j.shell.state.ErrorWhileInTransactionException: An error occurred while in an open transaction. The transaction will be rolled back and terminated. Error: Tried to ex
ecute Schema modification after executing Write query
        at org.neo4j.shell.state.BoltStateHandler.handleException(BoltStateHandler.java:215)
        at org.neo4j.shell.CypherShell.executeCypher(CypherShell.java:147)
        at org.neo4j.shell.CypherShell.execute(CypherShell.java:113)
        at org.neo4j.shell.cli.NonInteractiveShellRunner.runUntilEnd(NonInteractiveShellRunner.java:91)
        at org.neo4j.shell.Main.runShell(Main.java:165)
        at org.neo4j.shell.Main.startShell(Main.java:118)
        at org.neo4j.shell.Main.main(Main.java:88)
Caused by: org.neo4j.driver.exceptions.ClientException: Tried to execute Schema modification after executing Write query
        at org.neo4j.driver.internal.util.Futures.blockingGet(Futures.java:143)
        at org.neo4j.driver.internal.InternalTransaction.run(InternalTransaction.java:60)
        at org.neo4j.shell.state.BoltStateHandler.getBoltResult(BoltStateHandler.java:559)
        at org.neo4j.shell.state.BoltStateHandler.runCypher(BoltStateHandler.java:451)
        at org.neo4j.shell.CypherShell.executeCypher(CypherShell.java:136)
        ... 5 more
        Suppressed: org.neo4j.driver.internal.util.ErrorUtil$InternalExceptionCause
                at org.neo4j.driver.internal.util.ErrorUtil.newNeo4jError(ErrorUtil.java:85)
                at org.neo4j.driver.internal.async.inbound.InboundMessageDispatcher.handleFailureMessage(InboundMessageDispatcher.java:119)
                at org.neo4j.driver.internal.messaging.common.CommonMessageReader.unpackFailureMessage(CommonMessageReader.java:83)
                at org.neo4j.driver.internal.messaging.common.CommonMessageReader.read(CommonMessageReader.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.fireChannelRead(ByteToMessageDecoder.java:311)
                at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:432)
                at org.neo4j.driver.internal.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
                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:166)
                at org.neo4j.driver.internal.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)
                at org.neo4j.driver.internal.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
                at org.neo4j.driver.internal.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
                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:986)
                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)

I haver a backup from like 2 moths ago and works fine. Also, we just started to use the lucerne index, I do not know if that might be a problem.

Thanks in advance!

1 REPLY 1

Can you please create a apoc GitHub issue about this, where you share your neo4j version, apoc version and the exported cypher file.

It might be a generation issue where a :BEGIN :COMMIT block wraps both a schema and a data operation.

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.