You can use the appointNewDgraphLeader.sh script to appoint a new Dgraph leader.
The use case for this script is when there is a long-running ingest in progress in the Dgraph HDFS Agent, and the Dgraph goes down for some reason. Instead of waiting until a new write request comes in, the administrator can just run this script to restart the ingest on another machine. (A file is maintained in HDFS that logs the exact progress of the ingest. The newly-appointed Dgraph HDFS Agent leader reads the file and knows at what point to pick up the ingest).
For example, the Dgraph HDFS Agent on Dgraph_A is performing an ingest when the Dgraph crashes (which results in the ingest being suspended). When the script is run, the new leader can be Dgraph_B, in which case the ingest is picked up at the point when it was stopped (except that Dgraph_B is now performing the ingest instead of Dgraph_A). Because there is only one index shared among the Dgraphs, the ingest can be resumed by the new leader.
Note that if the script is run but a new leader has been appointed in the interim, then the script basically reappoints the same leader.
./appointNewDgraphLeader.sh <dg_address>where dg_address is the FQDN (fully-qualified domain name) and port of the Dgraph Gateway server. For example:
./appointNewDgraphLeader.sh web009.us.example.com:7003
To appoint a new Dgraph leader:
New Dgraph Leader appointed
Unable to appoint new Dgraph leader Could not reach Dgraph gateway
Note that an unsuccessful attempt could be caused by an incorrect address.