-
Notifications
You must be signed in to change notification settings - Fork 800
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
Update mutable state to generate workflow requests #5821
Conversation
Pull Request Test Coverage Report for Build 018eea45-745a-45b9-9dc1-c4e30fd5979fDetails
💛 - Coveralls |
1497967
to
5899eb4
Compare
a2f6f2d
to
efb6994
Compare
) | ||
if t, ok := err.(*persistence.DuplicateRequestError); ok { | ||
if t.RequestType == persistence.WorkflowRequestTypeStart || (isSignalWithStart && t.RequestType == persistence.WorkflowRequestTypeSignal) { |
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.
should we check (!isSignalWithStart && t.RequestType == persistence.WorkflowRequestTypeStart) || (isSignalWithStart && t.RequestType == persistence.WorkflowRequestTypeSignal)
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.
no, start is included in signalwithstart request
) | ||
if t, ok := err.(*persistence.DuplicateRequestError); ok { |
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.
nit: prefer errors.Is(err, persistence.DuplicateRequestError)
. That'll allow us to provide further information for the error in the future without affecting the control flow
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.
need type assertion, because we need to retrieve runID from the error
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.
errors.As
would do the job then
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.
yes, my apologies, errors.As
, though be careful to test it, it's double-pointer API is kinda confusing.
var e *persistence.DuplicateRequestError
if errors.As(err, &e) {
...
}
@@ -3101,3 +3112,75 @@ func TestUpdateWorkflowExecutionWithNewAsPassive(t *testing.T) { | |||
}) | |||
} | |||
} | |||
|
|||
func TestValidateWorkflowRequestsAndMode(t *testing.T) { |
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.
Will you have a unit test that covers the error case in the conflict resolution flow for this change when that's updated?
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 to the extent that I've been following + some nits
What changed?
This PR is built on top of #5826.
In this PR, we generate workflow requests from external API requests and replication events and store them in database to detect duplicated requests. If a duplicated requests is detected, a DuplicateRequestError is returned by persistence layer with the run_id telling upper layer which run the request has been applied to. And when this error is returned, the API does no-op and return the run_id to the caller.
Why?
To improve idempotency of Cadence APIs
How did you test it?
unit tests
Potential risks
We have a feature flag to turn on/off this feature. And we'll rollout this feature at domain level.
Release notes
Documentation Changes