Skip to content

Commit

Permalink
Minor race prevention: do not mutate callers' retry policy (#1413)
Browse files Browse the repository at this point in the history
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.

The fix is easy: just don't do that :)  There's no benefit to mutating it, and many downsides.
  • Loading branch information
Groxx authored Dec 13, 2024
1 parent 2bceb13 commit 1fd8ba0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())),
Expand All @@ -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
}

0 comments on commit 1fd8ba0

Please sign in to comment.