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

Ability for certain task failure types to fail workflow #516

Merged
merged 2 commits into from
Apr 30, 2024

Conversation

cretz
Copy link
Member

@cretz cretz commented Apr 25, 2024

What was changed

  • Added workflow_failure_exception_types to Worker to allow configuring failure exception types at a worker level
  • Added failure_exception_types to @workflow.defn to allow configuring failure exception types at a workflow level
  • Updated bridge code to include worker-level and workflow-type-level non-determinism-as-fail based on the presence of temporalio.workflow.NondeterminismError (or super type) in worker/workflow options
  • Documented in README, API doc, and marked experimental
  • Several tests for several scenarios

It's no coincidence this mimics temporalio/sdk-dotnet#205. Also see the feature issue at temporalio/features#322.

Checklist

  1. Closes [Feature Request] Configurable workflow failure exception types #446

@cretz cretz requested a review from a team as a code owner April 25, 2024 21:54
README.md Outdated Show resolved Hide resolved
temporalio/worker/_replayer.py Outdated Show resolved Hide resolved
Comment on lines +43 to +45
# Also, we have to re-import the worker-level exception types, because
# some exceptions are not passthrough and therefore our issubclass fails
# because it'll be comparing out-of-sandbox types with in-sandbox types
Copy link
Member

Choose a reason for hiding this comment

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

eww, that kinda sucks. Not that there's anything to be done about it really I guess, but, eww.

Copy link
Member Author

Choose a reason for hiding this comment

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

I couldn't think of a better way and I'm sure TS will have this problem too. Basically we want to support subtype checking for this, but in some cases Python sandbox reloads a user type inside the sandbox and it'll fail to match what was set outside the sandbox.

Another option here would be to not allow this to be set on the worker but instead make a new interceptor method that could be overridden to determine whether an exception was task fail or workflow fail. But I figured reloading was the best from a user POV.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah this is definitely better for the user. Hopefully not fragile.

Copy link
Member Author

@cretz cretz Apr 26, 2024

Choose a reason for hiding this comment

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

It is a bit fragile for advanced cases, but this is what that "prepare workflow" concept is for. It creates a workflow in the sandbox on worker start just as if it got work for that workflow in an attempt to fail quickly for anything not sandbox compatible. We also make sure that none of this applies if the user didn't opt-in to this experimental setting.

@cretz cretz merged commit 0bb94f8 into temporalio:main Apr 30, 2024
12 checks passed
@cretz cretz deleted the workflow-failure-exception-types branch April 30, 2024 17:33
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.

[Feature Request] Configurable workflow failure exception types
2 participants