Supplied Bookmark Does Not Conform to Pattern Error

Hello everyone,

I am building an application that needs to execute lots of Cypher statements against Neo4j. I execute these statements in 10K batches and commit them, however I often run into an error:

Supplied bookmark does not conform to pattern neo4j:bookmark:v1:tx

I am not sure what to do about it and I don't know why it is occurring. Here is the snippet of code that is executing the statements:

 with driver.session() as session:
# _batch_statements just yields batches of 10K cypher statements from the list statements
            for batch in _batch_statements(statements):
                with session.begin_transaction() as tx:
                    for statement in batch:

Anyone have any ideas as to why this would happen? any potential solutions?

I have been doing more testing and it appears there is a second error thrown as well:

Failed to read from defunct connection Address(host='localhost', port=7687) (Address(host='', port=7687))

Both of these errors are thrown as the same time.

Looking at the neo4j debug log and comparing it to my application's log this error seems to coincide with the errors above:

ERROR [o.n.b.r.DefaultBoltConnection] Protocol breach detected in bolt session 'bolt-0'. Message 'ROLLBACK' cannot be handled by a session in the READY state.
org.neo4j.bolt.runtime.BoltProtocolBreachFatality: Message 'ROLLBACK' cannot be handled by a session in the READY state.
at org.neo4j.bolt.runtime.statemachine.impl.AbstractBoltStateMachine.nextState(
at org.neo4j.bolt.runtime.statemachine.impl.AbstractBoltStateMachine.process(
at org.neo4j.bolt.messaging.BoltRequestMessageReader.lambda$doRead$1(
at org.neo4j.bolt.runtime.DefaultBoltConnection.lambda$enqueue$0(
at org.neo4j.bolt.runtime.DefaultBoltConnection.processNextBatchInternal(
at org.neo4j.bolt.runtime.DefaultBoltConnection.processNextBatch(
at org.neo4j.bolt.runtime.DefaultBoltConnection.processNextBatch(
at org.neo4j.bolt.runtime.scheduling.ExecutorBoltScheduler.executeBatch(
at org.neo4j.bolt.runtime.scheduling.ExecutorBoltScheduler.lambda$scheduleBatchOrHandleError$3(
at java.base/java.util.concurrent.CompletableFuture$
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.base/java.util.concurrent.ThreadPoolExecutor$
at java.base/

Another update: Previous executions were run from a docker container neo4j running on a laptop. I went ahead and executed the exact same code against a neo4j instance running on a server with a lot of resources and it all executed just fine. Maybe this is a resource utilization issue?

It might be, another thing I would check is server versions and bolt driver versions and make sure they match.

1 Like

I've also seen this error -- for the first time, recently. And, this is a recent post. What is the server version? Mine is (now) 4.1.0, and so I wonder if the python driver isn't in sync with the new server version.

1 Like

Yeah, "pip uninstall neotime neo4j neobolt" then "pip install neo4j" was the winner. Thanks.

For anyone else headed this way, some methods have changed, but wasn't too terrible to update code.

1 Like

Thanks for the confirmation and documenting it here!

Sorry for the delayed response! I am leaning toward a driver compatibility issue as well. Ran the tool again on the laptop with the same version of Neo4j as the server and it all executed as expected. Looks like I will need to be updating my tool to work with the 4.0 driver soon. Thanks all!