Dgraph alpha's --my flag doesn't work correctly

Moved from GitHub dgraph/5639

Posted by ahsanbarkati:

What version of Dgraph are you using?


Have you tried reproducing the issue with the latest release?


What is the hardware spec (RAM, OS)?

RAM: 4 GB, OS: Ubuntu 16.04

Steps to reproduce the issue (command/config used to run Dgraph).

  • Run the zero → dgraph zero
  • Run the alpha with --my flag → dgraph alpha --lru_mb=1024 --my=
  • Run the ratel.

Expected behaviour and actual result.

I expect that the --my flag to set the internal-gRPC’s ip:port and the --port_offset to offset the other two ports with respect to the internal-gRPC’s.

But, actually the alpha keeps on throwing the following message infinitely.

E0612 03:19:00.902077   10768 groups.go:1095] Error from alpha client subscribe: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp connect: connection refused"

Although, I am able to use ratel for mutations and query as usual.

OmarAyo commented :

hey @ahsanbarkati,

Are you sure that 7777 is the correct port of your alpha instance ? may you try with 6080 instead

ahsanbarkati commented :

Hi @OmarAyo,
I get the same result with 6080 as well.

OmarAyo commented :

are you specifying the -p and the -w directories for alpha ?

Maybe try to specify them and give it re-try

ahsanbarkati commented :

Tried doing it. It works the same as before. I am able to query and mutate as before but alpha keeps showing the error that I mentioned.

OmarAyo commented :

strange as I am able to get that error if I use the 7777 port and if I do not specify p and w dirs, maybe we can have a quick call where you can show me the issue

Is this error reproducible with v20.03.3 ?

ahsanbarkati commented :

Yes. Sure!
This error is reproducible with 20.03.3

OmarAyo commented :

As we saw, this will work only if --my=localhost:7080 and we have labeled this as bug

danielmai commented :

You need to set the --port_offset so that Alpha binds to the right ports. The my flag does not change the port binding.

For example,

dgraph alpha --my=localhost:7081 --port_offset=1

See the test docker-compose.yml for how it’s done in practice. The tests run with a port offset of 100, 102, 103, etc. and sets the --my flag to the appropriate address and port per instance.

MichelDiz commented :

I think this is not a bug. But a typo, due to the lack of knowledge about how the flag works. Maybe it would be better instead of write manually the PORT in --my flag. If you just ask the URL. And the port Dgraph would “append” based on the offset.

ahsanbarkati commented :

@MichelDiz or we might have it the other way. Dgraph could figure out the offset based on the port specified in the --my option. This seems more natural to me. What do you think?

MichelDiz commented :

@ahsanbarkati in that case, would not be better to have like --my localhost --port 7777?

The offset was created to avoid collision on Ports. Trying to base the offset using the --my flag can be tricky. Lead to mistakes/typos (It would be okay, but is it the best way?). So it would be better to have a flag just to define the port and Dgraph adds the offset based on that port. Like OFFSET=9080-7777. That would be friendly to anyone who doesn’t want to do the math.

Or even better. Do it based on the offset only. --my localhost --port_offset 1303 and Dgraph do the math and append it as I mentioned before. Although not friendly.

ahsanbarkati commented :

@MichelDiz Yup, both the ideas --my localhost --port 7777 and --my localhost --port_offset 697 seems good. I guess the second one could be preferred because the users of Dgraph might be more familiar with the offset notion.