question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support configuring per-method retryPolicy for gRPC channel

See original GitHub issue

Description

io.quarkus.grpc.runtime.supports.Channels is responsible for producing instances of io.grpc.Channel. Most of io.grpc.Channel properties are set from application.properties. But not all. I’m looking for a way to call io.grpc.ManagedChannelBuilder#defaultServiceConfig to configure retry policy. This is needed to make gRPC retry actually work.

Setting quarkus.grpc.clients."service-name".retry=true is not enough. It enables retry subsystem, but retry policy must be enabled and configured for each method individually.

See this question and its links for more details: https://stackoverflow.com/questions/65701091/how-to-get-grpcs-retry-mechanism-to-work-using-grpc-java-in-kubernetes-cluster

Also official docs for gRPC retry: https://github.com/grpc/proposal/blob/master/A6-client-retries.md

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mkoubacommented, Jun 17, 2021

There are couple of things we need to consider:

  • The retry policy is part of the service config which is bound to a Channel instance via io.grpc.internal.AbstractManagedChannelImplBuilder.defaultServiceConfig()
  • A Channel instance is created per client configured via GrpcClientConfiguration
  • So in therory, a Channel instance can be shared for multiple services…

The tricky part is that if we want to configure the retry policy per method then the config properties would have include the method name, e.g. something like quarkus.grpc.clients.hello.method.SayHello.retry.max-attempts=2. But (1) properties names are very long and (2) even then we would not be able to distinguish methods of a specific service.

We can also support per-client configuration that would be applied to all methods of all services:

quarkus.grpc.clients.hello.retry.max-attempts=2
quarkus.grpc.clients.hello.retry.initial-backoff=0.5s
quarkus.grpc.clients.hello.retry.max-backoff=1s
quarkus.grpc.clients.hello.retry.backoff-multiplier=1
quarkus.grpc.clients.hello.retry.retryable-status-codes=UNAVAILABLE
1reaction
cescoffiercommented, Apr 5, 2021

Good question about the configuration. @michalszynkiewicz do we have some kind of support?

About @Retry in the next version it will work with method returning Uni. I don’t believe it will work for Multi. I said next version, as it needs Smallrye Fault Tolerance 5.x which will come with a Quarkus 2.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Transient fault handling with gRPC retries - Microsoft Learn
Configures a retry policy. This policy instructs clients to automatically retry gRPC calls that fail with the status code Unavailable .
Read more >
proposal/A6-client-retries.md at master · grpc ... - GitHub
Retry policies support configuring the maximum number of retries, ... The retry policy will be implemented in-between the channel and the ...
Read more >
Configuring gRPC retries - retinadata
Documentation talks about a configuration file to specify during client creation but not the file format. Someone in stackoverflow shows an ...
Read more >
grpc-java: setting enableRetry and maxRetryAttempt is not ...
1 Answer 1 ... Neither enableRetry() nor maxRetryAttempts() configures retry on a per-method basis. enableRetry() enabled the entire "subsystem," ...
Read more >
ManagedChannelBuilder (grpc-all 1.51.0 API)
Provides a service config to the channel. abstract T · directExecutor() ... Enables the retry and hedging subsystem which will use per-method configuration....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found