New transaction does not pick random stub when connected to more then one alpha node

Posted by igormiletic:

Version 2.0.1

  • When create client that connects to more then one stub, it does not pick random nodes for new transaction. It always talk to one node.

E.g.

Alpha-1 => IP 123.1.1.0
Alpha-2 => IP 123.1.1.1
Alpha-3 => IP 123.1.1.2

if you do something like:

val channel1: ManagedChannel = ManagedChannelBuilder.forAddress(“123.1.1.0”, port).usePlaintext(true).build
val stub1 = DgraphGrpc.newStub(channel1)

val channel2: ManagedChannel = ManagedChannelBuilder.forAddress(“123.1.1.1”, port).usePlaintext(true).build
val stub2 = DgraphGrpc.newStub(channel2)

val channel3: ManagedChannel = ManagedChannelBuilder.forAddress(“123.1.1.2”, port).usePlaintext(true).build
val stub3 = DgraphGrpc.newStub(channel3)

// and then create client
val stubs = Seq(stub1, stub2, stub3)
val client = new DgraphAsyncClient(stubs: _*)

// when you call newTrasaction it always goes only to one alpha node (e.g. Alpha-1)
client.newTransaction()

Expected: to randomly pick nodes (alpha-1, alpha-2, alpha-3)

mangalaman93 commented :

Hi @igormiletic

I modified the tests and printed the node that Alpha is connecting to, seems to connect to all of them. Could you let me know how you verified that the request was going to only one Alpha?

If you could share the code snippet of setting up the DgraphClient, that’d be great too.

Thanks