googleapis / googleapis/gapic-generator-go

Client-Side Retry Ignores 'maxAttempts' Configuration

Open
#545 7 comments 0 reactions 0 assignees View on GitHub
type: feature request
Dominant language
Go
Stars
305
Forks
60
Avg merge
1d 8h
Merged PRs (30d)
13

Description

This should be reproducible on release v0.18.4.

The [README](https://github.com/googleapis/gapic-generator-go#invocation) mentions gRPC server config can be used for client-side retry configuration in accordance with [AIP-4221](http://aip.dev/4221). Most of the retry configuration is generated correctly, but the `maxAttempts` attribute is completely ignored.

I verified the limit is ignored by adding a log statement to the `gax.APICall` function passed into `gax.Invoke` to observe the retries continuing beyond the provided limit. The retries appeared to follow the policy backoff parameters, and the call option was otherwise generated correctly as shown below.

Policy:
```
"retryPolicy": {
"initialBackoff": "0.250s",
"maxBackoff": "2s",
"maxAttempts": 8,
"backoffMultiplier": 2,
"retryableStatusCodes": [
"UNKNOWN",
"UNAVAILABLE"
]
}
```

Generated call option:
```
gax.WithRetry(func() gax.Retryer {
return gax.OnCodes([]codes.Code{
codes.Unknown,
codes.Unavailable,
}, gax.Backoff{
Initial: 250 * time.Millisecond,
Max: 2000 * time.Millisecond,
Multiplier: 2.00,
})
}),
```

Looking further into the gax package and specifically the Backoff struct, it doesn't look like there's any support for counting the number of attempts. The proposal [here](https://github.com/grpc/proposal/blob/master/A6-client-retries.md#maximum-number-of-retries) seems to indicate that an unavailable error should be returned after the max attempts are reached.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.