Understanding `--my` flag

I have a few questions regarding the --my flag.

  1. What does “my” stand for?
  2. How does zero's behavior change depending on whether the flag was supplied?
  3. Why is it necessary to supply the IP address or host name of machine/container where zero is running? eg. --my=IPADDR:5080?
  4. Ditto 2 and 3, but for server

“my address” (I’m not sure if I understood the question)

Providing “–my” address is mandatory. I’m not sure about behavior. It’s just a connection approach.

“The --my flag is the connection that Dgraph servers would dial to talk to zero.” From docs

“addr:port of this server, so other Dgraph servers can talk to this.” from code.


Thanks Michel for the quick response!

I did go through the docs before posting this, however, I was confused because in the Run Dgraph section of the tour, zero is initialized without specifying --my, and so is the server.

Also, I don’t quite understand why --my needs to be specified on both zero and server. Isn’t the --zero flag on the server sufficient to tell the server how to connect to zero? Why are both flags necessary?

Finally, can’t both zero and server figure out their own IP and port? I mention this because, although I’m not very familiar with Go, it’s trivial to do so in other languages/frameworks, such as JavaScript with express, so I’d be surprised if this was hard to code in Go.

As always, thanks for your patience and useful answers @MichelDiz :slight_smile:

When you do not put it it will keep the default addr. However, if you use settings like HA and etc. It is better to have an explicit configuration.

Well, many times the Dgraph might be being hosted in an environment like AWS or GKE. And these have specific rules that Dgraph does not control. Like DNS “dgraph-zero-0.dgraph-zero.default.svc.cluster.local:5080”.

It depends on the context, but technically Dgraph is not able to locate your iptables table for example or do a range search. If it’s all default it will work okay, now for Dgraph do analyze contexts it’s a bit complicated. It’s out of Dgraph’s scope.

Another problem is that the “Dgraph Server” does not know which “Dgraph Zero” you want it to be in. If you have a HA configuration for example. You must specify. For there may be “N” instances of Dgraph Zero running. Server instances would have no way of knowing which ones to follow.

Also if you change the offsets, would be a problem.

Dgraph is able to know its own configuration and not of third Dgraph instances wherever they are (e.g other network, other container). BTW You can even use “–bindall=true” when necessary.

A solution to this would be welcome with a PR. The go devs are focused on very specific things lately. I don’t know if this would be urgent. But as is, there is not much need for add some work on this feature.

1 Like

Hi all.

Very enlightening, @MichelDiz, thank you, but surely I’m missing something (I’m completely new to Dgraph so please be patient).

This is the simplest form of the problem I have:

% docker run -it dgraph/dgraph:latest dgraph zero --my "" --bindall=true 
I0404 15:07:16.780147       1 init.go:88] 

Dgraph version   : v1.0.13
Commit SHA-1     : 691b3b35
Commit timestamp : 2019-03-09 19:33:59 -0800
Branch           : HEAD
Go version       : go1.11.5

For Dgraph official documentation, visit https://docs.dgraph.io.
For discussions about Dgraph     , visit https://discuss.dgraph.io.
To say hi to the community       , visit https://dgraph.slack.com.

Licensed variously under the Apache Public License 2.0 and Dgraph Community License.
Copyright 2015-2018 Dgraph Labs, Inc.

I0404 15:07:16.780740       1 run.go:98] Setting up grpc listener at:
I0404 15:07:16.780878       1 run.go:98] Setting up http listener at:
badger 2019/04/04 15:07:16 INFO: All 0 tables opened in 0s
I0404 15:07:16.812100       1 node.go:151] Setting raft.Config to: &{ID:1 peers:[] learners:[] ElectionTick:100 HeartbeatTick:1 Storage:0xc0006d3290 Applied:0 MaxSizePerMsg:1048576 MaxCommittedSizePerReady:0 MaxUncommittedEntriesSize:0 MaxInflightMsgs:256 CheckQuorum:false PreVote:true ReadOnlyOption:0 Logger:0x1fc13d0 DisableProposalForwarding:false}
I0404 15:07:16.812701       1 node.go:295] Group 0 found 1 entries

My intention was to have a zero node listening on port 6543 (in reality this would be a random port generated by Nomad). However, the container listens to default port 5080. No matter what I do, it feels as if the container will listen to default port 5080.

Am I misunderstanding the meaning of the --my flag?

Thanks in advance.

This flag refers to the address itself. Although you should add the port to --my. The ports are managed by another flag. In this case -o, --port_offset.

-o, --port_offset int Value added to all listening port numbers. [Internal=7080, HTTP=8080, Grpc=9080]

If you add the flag -o 1 the ports will be 7081, 9081, 8081 and so on.


Thanks for the quick reply, @MichelDiz.

I read about the --port_offset flag. I think it might be useful in a number of situations, but in my case the scheduler is generating the ports for me, randomly. What I was really hoping for is a way to specify the port to use in an absolute manner, not as an offset with respect to a default value. I have no way to indicate the ports that way for Nomad. And I thought that was the purpose of the --my flag. Clearly it isn’t. I’m afraid that although I appreciate it, I’m failing to understand your explanation:

This flag refers to the address itself. Although you should add the port to --my.

But what’s the point of adding the port, then? If that value is always 5080 + <port_offset>, should I calculate it by hand anyway, and provide it, even if it would be a trivial calculation for the dgraph executable?

Well about the offset, I’m not aware of the details regard this. But I think it’s something technical, are settings set a long time ago in Dgraph.

--my It is an “input” flag. Not a setup settings. It serves to record information for Dgraph instances to use. So you need to add the port. It also serves to validate the address.

btw you have to notice that when you change the offset, it will change equally for all ports.

This is something that has always bothered me as well. It’s not the way most users would expect the program to behave. I’ll look into how hard it would be for --my to behave in a more intuitive way.