I am trying to set the trigger as given in apoc triggers documentation: https://neo4j.com/docs/apoc/current/overview/apoc.trigger/apoc.trigger.install/
I am getting this error:
Neo.ClientError.Procedure.ProcedureCallFailed
Failed to invoke procedure
apoc.trigger.install
: Caused by: java.lang.RuntimeException: No write operations are allowed directly on this database. Writes must pass through the leader. The role of this server is: FOLLOWER
I am running neo4j 5.20 as a docker container, and have also installed the apoc library. In my neo4j browser, Cluster role is showing as "primary".
Here's the command with which i am starting the container:
docker run --rm --network host -e NEO4J_AUTH=none
-v $PWD/data:/data
-v $PWD/apoc.conf:/var/lib/neo4j/conf/apoc.conf
-v $PWD/plugins:/plugins
--name neo4j-apoc-new
-e NEO4J_apoc_export_file_enabled=true
-e NEO4J_apoc_import_file_enabled=true
-e NEO4J_apoc_import_file_use__neo4j__config=true
-e NEO4JLABS_PLUGINS=\[\"apoc\"\]
neo4j:5.20.0
I found this issue: https://github.com/neo4j-contrib/neo4j-apoc-procedures/issues/3073, but could't figure out whats wrong.
To quote the docs:
The
apoc.trigger.*
procedures are intended to be executed in the system database, therefore they have to be executed by opening a system database session.There are several ways of doing this:
When using Cypher-shell or Neo4j Browser, prefix Cypher queries with
:use system
When using Fabric, prefix Cypher queries with
USE system
When using the drivers, open a session directly against the system database
Moreover, the
apoc.trigger
procedures accept as first parameter the name of the database in which the triggers should be installed, updated, or removed.
So, for example, if you are using the Neo4j Browser, make sure it is in the system
database (which Neo4j automatically created) before calling apoc.trigger.install
:
:use system
CALL apoc.trigger.install(...)