Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support activity retry delay #571

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

dandavison
Copy link
Contributor

@dandavison dandavison commented Jul 5, 2024

Fixes #468

Support setting next_retry_delay when raising ApplicationError from activity code.

Evidence that this is correct

PR contains an integration test.

@dandavison dandavison requested a review from a team as a code owner July 5, 2024 14:16
Comment on lines 848 to 850
delay = google.protobuf.duration_pb2.Duration()
delay.FromTimedelta(error.next_retry_delay)
failure.application_failure_info.next_retry_delay.CopyFrom(delay)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
delay = google.protobuf.duration_pb2.Duration()
delay.FromTimedelta(error.next_retry_delay)
failure.application_failure_info.next_retry_delay.CopyFrom(delay)
failure.application_failure_info.next_retry_delay.FromTimedelta(error.next_retry_delay)

I wonder if this code works instead of a create-then-copy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, yes it seems to.

Comment on lines 120 to 121
a delay before the next activity retry. Ignored if set when raising
ApplicationError from workflow code.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe the last sentence is true anymore: temporalio/api#426



async def test_activity_retry_delay(client: Client):
retry_delay = timedelta(seconds=2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this make the test take 2 seconds? I think we can just check whether the property was accepted by the server and set on the way back (e.g. see https://github.com/temporalio/sdk-dotnet/pull/254/files#diff-bfb9d5dbaaa6ec1dfd5ce1837ad44f89fdb2bb75195af55b207ea9627a521eb6) instead of the actual server behavior

Copy link
Contributor Author

@dandavison dandavison Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@cretz cretz Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just test whether the exception has this property set instead of testing server behavior. These kinds of tests that have code duration expectations become flaky in slower environments. Here's an example in .NET where we only confirm property is set, not actual server timing: https://github.com/temporalio/sdk-dotnet/blob/4a6d4a0e886360242ea66d3402095b9b4406d690/tests/Temporalio.Tests/Worker/WorkflowWorkerTests.cs#L4557. I think we should be able to trust if the server has the property set it will do the right thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose next retry delay on Application Failure in all SDKs
2 participants