Skip to content

Commit

Permalink
[temporalio#1727] Use default RetryOptions for LocalActivities when n…
Browse files Browse the repository at this point in the history
…ot set or setMaximumAttempts(0)

Setting setMaximumAttempts=0 (or not setting any value, default = 0) for local activities should make the activity retry forever.

This is currently broken because the logic treats both no policy set and a policy with all default values (including MaxiumAttempts = 0)
as abort conditional.  What should happen (at least according the doc and to align with normal activities) is that no policy set should
be processed according to the default values of the retry policy, which includes unlimited retries when the MaxiumAttempts = 0.

Fixes temporalio#1727

Signed-off-by: Greg Haskins <[email protected]>
  • Loading branch information
ghaskins committed Oct 7, 2024
1 parent 089bbea commit 8201f72
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ private void submitAttempt(
slotQueue.submitAttempt(reservationDat, isRetry, task);
}

private RetryOptions getRetryOptions(PollActivityTaskQueueResponseOrBuilder activityTask) {
if (isRetryPolicyNotSet(activityTask)) {
return RetryOptions.getDefaultInstance();
} else {
return RetryOptionsUtils.toRetryOptions(activityTask.getRetryPolicy());
}
}

/**
* @param executionContext execution context of the activity
* @param activityTask activity task
Expand Down Expand Up @@ -154,11 +162,7 @@ private RetryDecision shouldRetry(
throw (Error) attemptThrowable;
}

if (isRetryPolicyNotSet(activityTask)) {
return new RetryDecision(RetryState.RETRY_STATE_RETRY_POLICY_NOT_SET, null);
}

RetryOptions retryOptions = RetryOptionsUtils.toRetryOptions(activityTask.getRetryPolicy());
RetryOptions retryOptions = getRetryOptions(activityTask);

if (RetryOptionsUtils.isNotRetryable(retryOptions, attemptThrowable)) {
return new RetryDecision(RetryState.RETRY_STATE_NON_RETRYABLE_FAILURE, null);
Expand Down Expand Up @@ -368,11 +372,7 @@ private RetryState shouldStillRetry(
@Nullable Failure previousLocalExecutionFailure) {
int currentAttempt = activityTask.getAttempt();

if (isRetryPolicyNotSet(activityTask)) {
return RetryState.RETRY_STATE_RETRY_POLICY_NOT_SET;
}

RetryOptions retryOptions = RetryOptionsUtils.toRetryOptions(activityTask.getRetryPolicy());
RetryOptions retryOptions = getRetryOptions(activityTask);

if (previousLocalExecutionFailure != null
&& previousLocalExecutionFailure.hasApplicationFailureInfo()
Expand Down

0 comments on commit 8201f72

Please sign in to comment.