From 6f538178b2f01fd4d2307e1933a604be01e2821f Mon Sep 17 00:00:00 2001 From: Steven L Date: Thu, 12 Dec 2024 18:39:20 -0600 Subject: [PATCH] Minor race prevention: do not mutate callers' retry policy Concurrently calling `workflow.WithActivityOptions` with a shared retry policy instance that does not set a backoff coefficient can trigger a race because this function mutated it unnecessarily. Easy fix: just don't do that :) --- internal/workflow.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/workflow.go b/internal/workflow.go index 6d84e8d8e..0545f808b 100644 --- a/internal/workflow.go +++ b/internal/workflow.go @@ -1849,9 +1849,6 @@ func convertRetryPolicy(retryPolicy *RetryPolicy) *s.RetryPolicy { if retryPolicy == nil { return nil } - if retryPolicy.BackoffCoefficient == 0 { - retryPolicy.BackoffCoefficient = backoff.DefaultBackoffCoefficient - } thriftRetryPolicy := s.RetryPolicy{ InitialIntervalInSeconds: common.Int32Ptr(common.Int32Ceil(retryPolicy.InitialInterval.Seconds())), MaximumIntervalInSeconds: common.Int32Ptr(common.Int32Ceil(retryPolicy.MaximumInterval.Seconds())), @@ -1860,5 +1857,8 @@ func convertRetryPolicy(retryPolicy *RetryPolicy) *s.RetryPolicy { NonRetriableErrorReasons: retryPolicy.NonRetriableErrorReasons, ExpirationIntervalInSeconds: common.Int32Ptr(common.Int32Ceil(retryPolicy.ExpirationInterval.Seconds())), } + if *thriftRetryPolicy.BackoffCoefficient == 0 { + thriftRetryPolicy.BackoffCoefficient = common.Float64Ptr(backoff.DefaultBackoffCoefficient) + } return &thriftRetryPolicy }