apoc.custom.installProcedure not allowed because of the "FOLLOWER" role

Hi all,

I'm new to Neo4j DBMS and need help with creating a custom procedure.

I'm trying to execute:

CALL apoc.custom.installProcedure(
    'my_procedure(param1::STRING) :: (result::STRING)',
    'MATCH (n:$param1) RETURN n.name AS result'
);

However, I get the following error:

Failed to invoke procedure `apoc.custom.installProcedure`: 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

This suggests that the database is running in a clustered environment with the server in FOLLOWER mode.

I'm using Neo4j 5.24.0 on Neo4j Desktop 1.6.1.122.
I just installed Neo4j Desktop and created a new database with the default configuration.

After encountering this issue, I checked the configuration file for settings related to standalone/cluster mode and LEADER/FOLLOWER roles but couldn't find anything that explicitly allows switching modes or roles (or, at least, I didn't recognize them).

I’m not even sure if my database instance is actually running in cluster mode, since I didn’t configure anything to enable it, unless cluster mode is the default (which seems unlikely).

Can anyone help me find a way to create custom procedures in my database installation?

Thank you!

P.S.
I found this parameter in the configuration file:

# Restrict the modes of databases that can be hosted on this server  
# Allowed values:  
# PRIMARY - Hosts standalone databases and members of the consensus quorum for a multi-primary database.  
# SECONDARY - Only hosts read replicas, eventually-consistent read-only instances of databases.  
# NONE - Can host databases in any mode.  
#initial.server.mode_constraint=NONE  

I then set:

initial.server.mode_constraint=PRIMARY  

hoping that this would force the server to run in standalone mode.
However, when I tried to create the custom procedure again, I encountered the same issue.

@fisherman_2022

if you run cypher

show servers;

this will report # of servers in the cluster. if you have only 1 entry then its not a cluster?

if you run

show databases;

this will report the databases in the DBMS and also report a role indicating if primary or secondary

There is an error in query that will surface when you call the procedure to execute your procedure. Here is a corrected version.

CALL apoc.custom.installProcedure(
    'my_procedure(param1::STRING) :: (result::STRING)',
    'MATCH (n:$($param1)) RETURN n.name AS result'
);

@glilienfield

Thank you for checking.
Unfortunately, I still get the same error message.

@dana_canzano

show servers:

name                                   address          state     health      hosting  
1  "e2dba70b-a90c-4f57-8ec3-8ded25850240"  "localhost:7687"  "Enabled"  "Available"  ["neo4j", "system"]  

show databases:

   name      type       aliases  access       address          role      writer  requestedStatus  currentStatus  statusMessage  default  home  constituents  
"neo4j"   "standard"   []       "read-write"  "localhost:7687"  "primary"  true     "online"         "online"      ""           true    true   []  
"system"  "system"     []       "read-write"  "localhost:7687"  "primary"  true     "online"         "online"      ""           false   false  []  

I noticed that access=read-write, role=primary, and writer=true.
I'm not entirely sure what these values imply, but they don’t seem to indicate any restrictive condition that would prevent the creation of a custom procedure.

Are you executing the install call through the system database, not the neo4j database

@glilienfield

You know, before asking here, I asked ChatGPT if I had to "USE system" to create a custom procedure and it answered, guess what ... NO

Better rely on Natural Intelligence ...

Thank you a lot.

1 Like