Node unable to join cluster after being removed from the cluster
-
What version of Dgraph are you using? 1.0.4 (also tested in 1.0.3)
-
Have you tried reproducing the issue with latest release? Not the dev, only the released 1.0.4
-
What is the hardware spec (RAM, OS)? This was observed in a GCE 3-node cluster of 6cpu 16gb RAM and also tested locally with the same outcome
-
Steps to reproduce the issue (command/config used to run Dgraph).
- Boot a zero instance and its associated dgraph.
- Repeat two more times to get a 3-node cluster with replica=3
- Run
/removeNodeon the leader to remove node with idx/group=3/1 and idx/group=3/0 - Check that one node and its dgraphzero is now removed from
/state - In the removed node, delete folders and start zero again, followed by dgraph service.
- Expected behaviour and actual result. Expected behaviour would be to have the new node joining the current cluster. In reality, while dgraphzero does join the cluster, dgraph connects to its local dgraphzero but doesn't connect to the cluster. The only way to recover the cluster was to point dgraph to another dgraphzero (the current leader)
Did you stop the nodes before calling the /removeNode API as mentioned at https://docs.dgraph.io/deploy/#more-about-dgraph-zero?
I tried to reproduce this but couldn't. Could you share the logs from dgraph server which is not able to connect to the cluster? Also, did you start dgraph server using the idx flag?
Yes I also did stop the dgraph server and zero of one node before calling removeNode.
Sadly I don't have the logs, but was able to reproduce it locally. If you couldn't reproduce it, I can close the issue then.
I meant the logs in the failing production node. I will reproduce it again and get the logs ASAP
I have been able to reproduce the issue on another try. I am investigating why this happens.
Steps to reproduce
- Start three Zero servers.
./dgraph zero --replicas 3 --idx 1
./dgraph zero -w zw1 -o 1 --replicas 3 --peer localhost:5080 --idx 2
./dgraph zero -w zw2 -o 2 --replicas 3 --peer localhost:5080 --idx 3
- Stop the leader and remove it from the cluster.
# Stop the leader first. Assuming node with idx 1 is leader.
curl "localhost:6081/removeNode?group=0&id=1" && rm -rf zw
- Restart the node with a peer.
./dgraph zero --replicas 3 --idx 1 --peer localhost:5081
- Start a dgraph server pointing it to the restarted node.
./dgraph server --lru_mb 2048 -z localhost:5080
The node is stuck as seen in the logs below:
➜ dgraph git:(master) ✗ ./dgraph server --lru_mb 2048
2018/04/04 10:25:06 groups.go:86: Current Raft Id: 0
2018/04/04 10:25:06 worker.go:99: Worker listening at address: [::]:7080
2018/04/04 10:25:06 gRPC server started. Listening on port 9080
2018/04/04 10:25:06 HTTP server started. Listening on port 8080
2018/04/04 10:25:06 pool.go:118: == CONNECT ==> Setting localhost:5080
Somehow the RAFT proposal is stuck on the replaced Zero node and since we don't we have a timeout, there is no error. This problem doesn't occur if the Zero node being replaced is given a new id, i.e. say 4 instead of 1 in this case.
I can also observe a similar issue with Dgraph servers, i.e. a mutation is stuck when reusing ids.
After discussing with @janardhan1993, we have come to the conclusion that it is not recommended to reuse RAFT ids. We should throw an error if the user tries to reuse a RAFT id that is in the list of removed nodes.
So, if the w directory has been deleted and the node has already been removed from the cluster, a new node shouldn't join the cluster with the same id as that of the removed node. I will make the change to throw an error.
We now return an error after 2bfa4bbd139fa7fac10d612e32f61f3d2c05ba28.