-
Notifications
You must be signed in to change notification settings - Fork 225
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
Fix child WF ID generation #1803
base: master
Are you sure you want to change the base?
Conversation
Questions here:
|
Java seems to be generating UUIDs when an ID is not provided in ChildWorkflow options. Additionally when I replayed an existing
Absolutely yes. Java seems to be already doing this (at least in my testing). Looks like it changes the seed at reset-point?
Yes. So far all server versions have prevented resetting of workflows when the reset point falls in between child Init & Completed events (i.e within the lifespan of child). So no potential user impact or backward compatibility issues there.
Yes it is possible to have these two values different at child creation time. When the reset-point is outside the child's lifespan (Init - Completed) then the server has always allowed resets. So in cases when the reset-point is before the child-init, the parent will try to create a child again and this time |
@gow - thanks for this info! So reading all of that I am seeing two things:
For 1, I will start an internal discussion and invite you. Regardless, I am not sure the desired outcome is what is in this PR. |
The desired outcome of this PR is for Go-SDK to be able to replay |
Putting this on hold. Will discuss internally and work on a better fix. |
c54c992
to
ab1a0c3
Compare
ab1a0c3
to
f0eb17d
Compare
After an internal discussion, we decided to bring Go SDK on par with the rest of the SDKs. So instead of simply using OriginalRunID, we are using the |
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.
overall LGTM, deferring to @Quinn-With-Two-Ns or @cretz for approval. I vaguely remember there was a test they were hoping was added, but can't remember exactly what that test was.
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 vaguely remember there was a test they were hoping was added, but can't remember exactly what that test was.
We need to add some integration tests here. I'm trying to figure out the structuring and setup of them in this codebase. I'll probably sync with you all offline to get some pointers.
@@ -492,8 +492,7 @@ OrderEvents: | |||
break OrderEvents | |||
} | |||
case enumspb.EVENT_TYPE_WORKFLOW_TASK_SCHEDULED, | |||
enumspb.EVENT_TYPE_WORKFLOW_TASK_TIMED_OUT, | |||
enumspb.EVENT_TYPE_WORKFLOW_TASK_FAILED: |
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.
@Quinn-With-Two-Ns - can you think of any ramifications for now putting workflow task failed events in taskEvents.events
where we hadn't before?
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.
LGTM, though now we get into the more fun challenge of adding tests, heh
test/replaytests/replay_test.go
Outdated
@@ -493,6 +493,24 @@ func (s *replayTestSuite) TestPartialReplayNonCommandEvent() { | |||
require.NoError(s.T(), err) | |||
} | |||
|
|||
func (s *replayTestSuite) TestResetWorkflowWithChildSuccess() { |
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.
These don't seem to have resets in them. Here's my best guess on some tests needed:
- Capture a JSON of a before-this-PR-change workflow that completed that has a reset after child workflow, and confirm it replays properly
- Capture a JSON of a before-this-PR-change workflow that completed that has a before-this-PR-change reset before child workflow, and confirm it replays properly because it created a whole new child workflow
- Make workflow with two child workflows, run it to completion, reset to in-between those two child workflows and let that reset one run to completion too. Confirm both replay successfully. Confirm that the original workflow's first child ID (i.e. the pre-reset-point one) is the same as the new workflow's first child ID by looking at history. Confirm the original workflow's second child ID (i.e. the post-reset-point one) is not the same as the new workflow's second child ID.
Those are the primary three I can think of, @Quinn-With-Two-Ns probably knows more. And you may want more to test certain behaviors such as the fact that the default parent close policy of terminate does what is expected.
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.
Sorry, I should have marked this as draft again. Still working on it. Just sent it to see the CI builds. Talked to @Quinn-With-Two-Ns and I'm adding the cases you mentioned except this one
Capture a JSON of a before-this-PR-change workflow that completed that has a reset after child workflow, and confirm it replays properly
Because before-this-PR-change is broken and doesn't replay properly. But reset before the child workflow was working. So adding that one.
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 think Chads point here was even though it doesn't replay properly with the current SDK, your change should cause it to replay properly
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.
Agree. I've added both cases.
Adding integration tests 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.
So you should be able to add 3 test since you can test 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.
The third case he mentioned above is an integration tests isn't 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.
It would be an integration test and a replay test. You have two scenarios:
-
Workflow was started with an old SDK, workflow had a child workflow and was reset after the child workflow finished. Currently that workflow is stuck due to NDE. Your change here should fix that workflow
-
Workflow started with a new SDK, workflow had a child workflow and was reset after the child workflow finished. Workflow should complete successfully
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.
- is a replay test, 2 is an integration test
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.
Got it. Done.
I added 1 integration test resetting a WF at 3 different reset points. The parent starts 2 children in sequence.
- Reset # 1 - before both children. Both have new IDs after reset.
- Reset # 2 - In between child-1 & child-2. Child-1 ID stays same. Child-2 ID changes.
- Reset # 3 - After both children. Both have the same IDs as before reset.
I think there are lot more tests we need to write related to resets in general that are outside the scope of this PR. We should probably add these in followup PRs just to increase coverage.
- Reset a running parent.
- Reset a completed (base) parent but with another execution already running.
- Reset a running/completed parent that handles a failed child.
- Reset a running/completed parent where the reset points are in between Child init and child completed events (coming up in next server version)
Also this |
@@ -2040,6 +2040,101 @@ func (ts *IntegrationTestSuite) TestResetWorkflowExecution() { | |||
ts.Equal(originalResult, newResult) | |||
} | |||
|
|||
// TestResetWorkflowExecutionWithChildren tests the behavior of child workflow ID generation when a workflow with children is reset. | |||
// It repeatedly resets the workflow at different points in its execution and verifies that the child workflow IDs are generated correctly. | |||
func (ts *IntegrationTestSuite) TestResetWorkflowExecutionWithChildren() { |
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 great test
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.
LGTM, but wait for @Quinn-With-Two-Ns to be able to look at test coverage and scenarios, he may be aware of more/better ones
What was changed
We now use
workflowInfo.OriginalRunID
in parent when it is generating a child workflow ID.Why?
We need this change to enable resetting of workflows that have pending children. What this means is Go SDK should be able to successfully replay
StartChildWorkflowExecutionInitiated
event in a parent that was reset.Without this change Go SDK will run into non-determinism error since the child ID it generates (based on new run ID) doesn't match with the ID available in the
StartChildWorkflowExecutionInitiated
event. SinceOriginalRunID
stays the same across resets, with this change the SDK can successfully replayStartChildWorkflowExecutionInitiated
events.Checklist
Closes
N/A
How was this tested:
Manually tested it. Added integration tests and replay tests.
Any docs updates needed?
N/A