Skip to content

Commit

Permalink
fix: Don't allow idx flag to be set to 0 on dgraph zero (#6156) (#6193)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahul Gurnani authored Aug 17, 2020
1 parent 86a796a commit 5102c1c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dgraph/cmd/zero/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ instances to achieve high-availability.
"addr:port of this server, so other Dgraph alphas can talk to this.")
flag.IntP("port_offset", "o", 0,
"Value added to all listening port numbers. [Grpc=5080, HTTP=6080]")
flag.Uint64("idx", 1, "Unique node index for this server.")
flag.Uint64("idx", 1, "Unique node index for this server. idx cannot be 0.")
flag.Int("replicas", 1, "How many replicas to run per data shard."+
" The count includes the original shard.")
flag.String("peer", "", "Address of another dgraphzero server.")
Expand Down Expand Up @@ -170,6 +170,10 @@ func run() {
rebalanceInterval: Zero.Conf.GetDuration("rebalance_interval"),
}

if opts.nodeId == 0 {
log.Fatalf("ERROR: idx flag cannot be 0. Please try again with idx as a positive integer")
}

if opts.numReplicas < 0 || opts.numReplicas%2 == 0 {
log.Fatalf("ERROR: Number of replicas must be odd for consensus. Found: %d",
opts.numReplicas)
Expand Down

0 comments on commit 5102c1c

Please sign in to comment.