-
Notifications
You must be signed in to change notification settings - Fork 825
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
Adds validation for workflow task for child start and cancel #599
Adds validation for workflow task for child start and cancel #599
Conversation
Adds validation to fail workflow task when child execution is started and cancelled in the same workflow task.
continueAsNewBuilder: nil, | ||
stopProcessing: false, | ||
mutableState: mutableState, | ||
initiatedChildExecutionsInSession: make(map[string]struct{}), |
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.
Do we have a similar problem with other commands? What about activities, timers, etc?
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 will add integration tests for timer and activity use cases in a separate PR.
continueAsNewBuilder mutableState | ||
stopProcessing bool // should stop processing any more commands | ||
mutableState mutableState | ||
initiatedChildExecutionsInSession map[string]struct{} // Set of initiated child executions in the workflow task |
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.
session is a new term. Should we call more like currentCommandBatch or something else?
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.
Changed to initiatedChildExecutionsInBatch
Co-authored-by: Alex Shtin <[email protected]>
What changed?
Adds validation to fail workflow task when child execution is started
and cancelled in the same workflow task.
Fixes #276
Why?
If client SDK starts a child workflow and then cancels it in the same workflow task Temporal
currently processes both these commands which results in the child workflow getting started
and then cancellation requested on it. This results in undesired behavior on the sdk, where much
better expectation is that child workflow is never started in the first place.
Initially we thought of implementing logic on the server to cancel the child execution immediately as
part of the workflow task processing. But after more thought it is not as simple as expected. Most
of the code around child workflows state machine is completely asynchronous and short circuiting
all that logic to synchronous cancel the child execution could be very risky.
So after discussion with @mfateev I decided to consider this as an invalid scenario and fail the entire
workflow task instead. We would add logic on the clients to never make this command if child is
started and cancelled in the same workflow task.
How did you test it?
Added new integration test
TestImmediateChildCancellation_WorkflowTaskFailed
Potential risks
This state machine already results in broken experience on SDK. Does not introduces any additional risk.