Let’s say I setup the client like this (there are separate instances of Dgraph running on ports 9080 and 9083)
ManagedChannel channel1 = ManagedChannelBuilder
.forAddress("localhost", 9080)
.defaultLoadBalancingPolicy("round_robin")
.defaultServiceConfig(serviceConfig)
.enableRetry()
.maxRetryAttempts(10)
.usePlaintext().build();
DgraphStub stub1 = DgraphGrpc.newStub(channel1);
ManagedChannel channel2 = ManagedChannelBuilder
.forAddress("localhost", 9083)
.defaultLoadBalancingPolicy("round_robin")
.defaultServiceConfig(serviceConfig)
.enableRetry()
.maxRetryAttempts(10)
.usePlaintext().build();
.usePlaintext().build();
DgraphStub stub2 = DgraphGrpc.newStub(channel2);
DgraphClient dgraphClient = new DgraphClient(stub1, stub2, stub3);
and my service config is:
{
"methodConfig": [
{
"name": [
{
"service": "api.Dgraph"
}
],
"retryPolicy": {
"maxAttempts": 5,
"initialBackoff": "0.5s",
"maxBackoff": "30s",
"backoffMultiplier": 2,
"retryableStatusCodes": [
"UNAVAILABLE",
"DEADLINE_EXCEEDED"
]
}
}
]
}
When both instances of Dgraph are up, I get a valid response to my queries. But, if I take one down, I just get a Connection refused
exception (and UNAVAILABLE
gRPC exception) when the request goes to that channel.
Note that, if the request goes to the channel still up, I do get a valid response.
With retry enabled, I would have expected the request to be sent to this channel one the first one fails.
For reference: