-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
neo4j.exceptions.ClientError: No write operations are allowed directly on this database. Writes must pass through the leader. The role of this server is: FOLLOWER #335
Comments
We are still getting this issue, even when forcing a write transaction. I've created a repro case: https://github.com/robertlagrant/neo4j-cluster-failure. Please test. |
@robertlagrant Would it be possible to share a little bit more information on your cluster configuration? Is that supposed to be 3 CORE servers? There are some conditions where what you describe might be the intended behaviour at least as far as RAFT is concerned (i.e. see this). I am trying to see how much of this can be dealt with at the level of |
Please see https://neo4j.com/docs/ogm-manual/current/reference/ (section 3.14.1.6. Retry mechanisms).
In other words, the driver does not deal with higher level failures (such as cluster disconnects). In our use cases we have worked around this by adding custom retry logic to our business logic. See very basic example down below (adding jitter and exponential backoff obviously highly recommended). sts = time.time()
while True:
last_exception = None
cts = time.time()
if cts - sts > _MAX_RETRY_SECONDS:
raise last_exception
try:
session.write_transaction(do_write())
break
except Exception as e:
time.sleep(1)
last_exception = e |
@mvanderkroon Thank you very much, sounds like a modification is required at this point (?). |
@aanastasiou I believe so. I have forked the repo, made the necessary changes and would be quite happy to issue a pull request. Should I point it to your |
@mvanderkroon Thank you very much and I do not see why not. It should be sent as a pull request to the main |
@aanastasiou sure - it's a 3 core server cluster. There are also 2 read replicas, but they don't really feature in this situation as far as I'm aware. |
@robertlagrant Thank you for your response, I think that the discussion with @mvanderkroon on the pull request was very informative about the specifics. |
Why follower cannot accept writes? |
@kant111 because that's not how Neo4J works. |
when using a connection URL of bolt+routing:// this indicates the session is now cluster aware, whereas bolt:// does not understand the other members in a cluster. |
Fun fact (tested on Neo4J 4.0.7) Adding a trigger can only be done on the node in the cluster that is the LEADER of both the DB you are adding the trigger to AND the system database (might need the neo4j DB as well, wasn't sure, but we don't use it). The example below is me trying to add a trigger whilst connected to the node
After a bunch of killing nodes and waiting for them to come back to the desired state, and connected to
|
A funny one:
bolt+routing
@db.transaction
We're getting intermittent errors as per the issue title - i.e. it's trying to write to a follower node, and presumably bolt+routing isn't sending the transaction to the leader.
Am I missing something? Is it that if the first interaction with the database is a read, that it opens the transaction on a follower node? Can I force it to the leader for every transaction?
The text was updated successfully, but these errors were encountered: