Skip to content

Commit f38c88a

Browse files
authored
Allow more retries for matching client polls (temporalio#8155)
## What changed? Allow frontend->matching poll requests to retry up to their context timeout instead of just once. ## Why? On matching service deployments, a busy new matching node may hit its persistence rps limit trying to acquire new task queues and be unable to accept polls. ## How did you test it? - [x] built - [ ] run locally and tested manually - [ ] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s)
1 parent fdb7f31 commit f38c88a

File tree

5 files changed

+26
-5
lines changed

5 files changed

+26
-5
lines changed

client/matching/retryable_client.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,21 @@ var _ matchingservice.MatchingServiceClient = (*retryableClient)(nil)
1010
type retryableClient struct {
1111
client matchingservice.MatchingServiceClient
1212
policy backoff.RetryPolicy
13+
pollPolicy backoff.RetryPolicy
1314
isRetryable backoff.IsRetryable
1415
}
1516

1617
// NewRetryableClient creates a new instance of matchingservice.MatchingServiceClient with retry policy
17-
func NewRetryableClient(client matchingservice.MatchingServiceClient, policy backoff.RetryPolicy, isRetryable backoff.IsRetryable) matchingservice.MatchingServiceClient {
18+
func NewRetryableClient(
19+
client matchingservice.MatchingServiceClient,
20+
policy,
21+
pollPolicy backoff.RetryPolicy,
22+
isRetryable backoff.IsRetryable,
23+
) matchingservice.MatchingServiceClient {
1824
return &retryableClient{
1925
client: client,
2026
policy: policy,
27+
pollPolicy: pollPolicy,
2128
isRetryable: isRetryable,
2229
}
2330
}

client/matching/retryable_client_gen.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/tools/genrpcwrappers/main.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"cmp"
45
"flag"
56
"fmt"
67
"io"
@@ -72,6 +73,11 @@ var (
7273
largeTimeoutContext = map[string]bool{
7374
"client.admin.GetReplicationMessages": true,
7475
}
76+
longPollRetryPolicy = map[string]string{
77+
"retryableClient.matching.PollWorkflowTaskQueue": "pollPolicy",
78+
"retryableClient.matching.PollActivityTaskQueue": "pollPolicy",
79+
"retryableClient.matching.PollNexusTaskQueue": "pollPolicy",
80+
}
7581
ignoreMethod = map[string]bool{
7682
// TODO stream APIs are not supported. do not generate.
7783
"client.admin.StreamWorkflowReplicationMessages": true,
@@ -387,6 +393,7 @@ func writeTemplatedMethod(w io.Writer, service service, impl string, m reflect.M
387393
"RequestType": reqType.String(),
388394
"ResponseType": respType.String(),
389395
"MetricPrefix": fmt.Sprintf("%s%sClient", strings.ToUpper(service.name[:1]), service.name[1:]),
396+
"RetryPolicy": cmp.Or(longPollRetryPolicy[key], "policy"),
390397
}
391398
if longPollContext[key] {
392399
fields["LongPoll"] = "LongPoll"
@@ -581,7 +588,7 @@ func (c *retryableClient) {{.Method}}(
581588
resp, err = c.client.{{.Method}}(ctx, request, opts...)
582589
return err
583590
}
584-
err := backoff.ThrottleRetryContext(ctx, op, c.policy, c.isRetryable)
591+
err := backoff.ThrottleRetryContext(ctx, op, c.{{.RetryPolicy}}, c.isRetryable)
585592
return resp, err
586593
}
587594
`)

common/resource/fx.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ func MatchingClientProvider(matchingRawClient MatchingRawClient) MatchingClient
272272
return matching.NewRetryableClient(
273273
matchingRawClient,
274274
common.CreateMatchingClientRetryPolicy(),
275+
common.CreateMatchingClientLongPollRetryPolicy(),
275276
common.IsServiceClientTransientError,
276277
)
277278
}

common/util.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ func CreateMatchingClientRetryPolicy() backoff.RetryPolicy {
178178
WithMaximumAttempts(matchingClientRetryMaxAttempts)
179179
}
180180

181+
// CreateMatchingClientLongPollRetryPolicy creates a retry policy for poll calls to matching service
182+
func CreateMatchingClientLongPollRetryPolicy() backoff.RetryPolicy {
183+
// no maximum attempts, using default expiration interval of 1 minute
184+
return backoff.NewExponentialRetryPolicy(matchingClientRetryInitialInterval)
185+
}
186+
181187
// CreateFrontendHandlerRetryPolicy creates a retry policy for calls to frontend service
182188
func CreateFrontendHandlerRetryPolicy() backoff.RetryPolicy {
183189
return backoff.NewExponentialRetryPolicy(frontendHandlerRetryInitialInterval).

0 commit comments

Comments
 (0)