-
Notifications
You must be signed in to change notification settings - Fork 33
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 #205
Ability for certain task failure types to fail workflow #205
Conversation
/// this exception can be used as a failure exception type to have non-deterministic exceptions | ||
/// fail workflows. | ||
/// </remarks> | ||
public class WorkflowNondeterminismException : InvalidWorkflowOperationException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So Java capitalizes the D
here but core does not, open to suggestions
bool nondeterminism_as_workflow_fail; | ||
/** | ||
* This is expected to be a newline-delimited list | ||
*/ | ||
struct ByteArrayRef nondeterminism_as_workflow_fail_for_types; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have these specially for nondeterminism rather than passing through the types and converting that to the Rust types?
If/when we add more types there will need to be two fields for every future type rather than just adding a branch to the converter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this is a private FFI boundary and I only expose the most I need. I am trying to avoid overcomplicating the FFI code until there is a second type. I would not be surprised if that enum stays as only one item forever, heh, but it's much easier for Rust to build those abstractions than C.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but, you've got to do the conversion either way. It's either the same amount of complicated, or if we ever add anything else, less complicated. You can just pass through an an enum or something, super simple, and less work to extend later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's more complicated to do C arrays (not "super simple") and I have been lucky to avoid them so far because I can make expectations about how I can split single-value fields. But it sounds like my luck is running out, ug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added string arrays in this commit and removed the newline restriction
src/Temporalio/Bridge/src/worker.rs
Outdated
opt.nondeterminism_as_workflow_fail_for_types | ||
.to_option_str() | ||
.map(|s| { | ||
s.split('\n') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could make the to map helper for this generic and use it here.
I'm still not a fan of parsing on newlines like this, but it's not hugely important to change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already have a map helper for metadata (and it's newline delimited too), but I admit being lazy, because getting collections of strings right in a non-annoying way over FFI boundary requires basically building your own structures (or saying something like \0
delimited) and I was hoping to avoid it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added string arrays in this commit and removed the newline restriction
/// <see cref="Exceptions.FailureException" /> + cancellation and suspend via task failure | ||
/// all others. But this default may change in the future. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// <see cref="Exceptions.FailureException" /> + cancellation and suspend via task failure | |
/// all others. But this default may change in the future. | |
/// <see cref="Exceptions.FailureException" />. Other exception types will cause either cancellation or suspension via task failure. This default may change in the future. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't necessarily true with how the code is today. I trap cancellation errors and return workflow fail even when cancellation was not requested because of how common they appear and that it's unfair to have already-started timer cancellation be a wf fail but not-yet-started timer cancellation be a task fail.
/// <see cref="Exceptions.FailureException" /> + cancellation and suspend via task failure | ||
/// all others. But this default may change in the future. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// <see cref="Exceptions.FailureException" /> + cancellation and suspend via task failure | |
/// all others. But this default may change in the future. | |
/// <see cref="Exceptions.FailureException" />. Other exception types will cause either cancellation or suspension via task failure. This default may change in the future. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See other comment on similar change
if (name != null && name.Contains('\n')) | ||
{ | ||
errs.Add("Workflow name cannot have a newline"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good example why the newline thing scares me.
I mean, it's dumb to have a newline in a workflow name anyway, but, still.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It already occurs with metadata today, but I am preventing the newline explicitly. I don't think this use case is worth me building my own C string vec representation. But I can if I must.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well does that really mean we need to build our own? I've got to imagine this comes up fairly often...
And yeah, I know it's happening with metadata but the fact that we'll sometimes have to deal with edge cases like this as we add new things says to me it probably is worth a little bit of effort to just deal with that problem for good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In C what you have to do is accept a pointer to the first element and then a length. And each element needs to know its size. And with ownership rules over FFI, it means each element needs to remain owned on the lang side. So it's a pointer to an owned array of pointers to owned strings. But this is totally doable, I've just avoided it because I've never needed it and it's ugly/dangerous. Didn't seem worth it just to keep newlines in workflow types, but I will try to add it now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added string arrays in this commit and removed the newline restriction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! Yeah, that looked pretty easy and worth it.
What was changed
TemporalWorkerOptions.WorkflowFailureExceptionTypes
to allow configuring failure exception types at a worker levelWorkflowAttribute.FailureExceptionTypes
to allow configuring failure exception types at a workflow levelInvalidWorkflowOperationException
into separate exceptions forInvalidWorkflowSchedulerException
andWorkflowNondeterminismException
WorkflowNondeterminismException
(or super type) in worker/workflow optionsChecklist