-
Notifications
You must be signed in to change notification settings - Fork 55
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
IWF-129: Enable executingStateIds SAs for states with waitUntil #453
Conversation
5a6ad52
to
7e56552
Compare
if config.GetDisableSystemSearchAttribute() { | ||
return nil | ||
} | ||
|
||
if e.globalVersioner.IsAfterVersionOfOptimizedUpsertSearchAttribute() && len(executingStateIds) == 0 { |
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 optimization is broken already for current default/ENABLED_FOR_ALL, and it won't work for ENABLED_FOR_STATES_WITH_WAIT_UNTIL. We need to fix it, and have to update ClearExecutingStateIdsSearchAttributeFinally
as well.
To keep determinsm, we have to add a IsBeforeVersionOfExecutingStateIdMode
in globalVersioner.
Then here:
if e.globalVersioner.IsAfterVersionOfOptimizedUpsertSearchAttribute() &&
e.globalVersioner.IsBeforeVersionOfExecutingStateIdMode() &&
len(executingStateIds) == 0 {
// explain why we stopped using this optimization
return nil
}
Similarly in ClearExecutingStateIdsSearchAttributeFinally:
if e.globalVersioner.IsAfterVersionOfOptimizedUpsertSearchAttribute() &&
e.globalVersioner.IsBeforeVersionOfExecutingStateIdMode() {
if if config.GetDisableSystemSearchAttribute() {
return
}
if e.totalCurrentlyExecutingCount == 0{
upsertSearchAttribute( []string{}) // clear the value.
}
}
Btw, you can also create a method in globalVersioner IsAfterVersionOfOptimizedUpsertSearchAttributeAndBeforeVersionOfExecutingStateIdMode()
to combinet this check. Maybe that will look better (maybe not, it looks hard to read actually)
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.
Btw, I realized that the correct way to optimize this UpsertSearchAttribute(which is a temporal action) is to check the next state like this: #454
We can also do it in next PR -- as long as we don't release the this PR to production, we don't have to create a new version (so that we don't keep too many versions)
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.
IsBeforeVersionOfExecutingStateIdMode
is equal to !IsAfterVersionOfExecutingStateIdMode
. Do we need an extra method for this check?
The latter method is somehow malformed in your snippet. I changed it to:
func (e *StateExecutionCounter) ClearExecutingStateIdsSearchAttributeFinally() {
config := e.configer.Get()
if e.globalVersioner.IsAfterVersionOfExecutingStateIdMode() {
if config.GetExecutingStateIdMode() == "DISABLED" {
return
}
} else {
if config.GetDisableSystemSearchAttribute() {
return
}
}
if e.globalVersioner.IsAfterVersionOfOptimizedUpsertSearchAttribute() && !e.globalVersioner.IsAfterVersionOfExecutingStateIdMode() && e.totalCurrentlyExecutingCount == 0 {
err := e.provider.UpsertSearchAttributes(e.ctx, map[string]interface{}{
service.SearchAttributeExecutingStateIds: []string{},
})
if err != nil {
e.provider.GetLogger(e.ctx).Error("error for upsert SearchAttributeExecutingStateIds", err)
}
}
}
We will need to refactor it further, since with how it is right now, SearchAttributeExecutingStateIds won't be cleared when e.globalVersioner.IsAfterVersionOfExecutingStateIdMode() == true
.
And I'd rather work on #454 in a separate branch. I can rebase off of this one and merge #454 into here before merging to main if we want to release other changes.
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.
IsBeforeVersionOfExecutingStateIdMode is equal to !IsAfterVersionOfExecutingStateIdMode. Do we need an extra method for this check?
You are right, we don't have to. Sometimes I just prefer to not use negative statement/expression (reasons are like https://www.obsidiansecurity.com/blog/why-to-stop-writing-negative-code/ )
But no much difference and it's not always the case.
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.
And I'd rather work on #454 in a separate branch. I can rebase off of this one and merge #454 into here before merging to main if we want to release other changes.
+1
Sounds good. btw maybe not add replay tests for this PR . Otherwise you will have to do it again (maybe it's fine) if we want to reuse the same version (because that optimization is a non-determinstic change)
9dcc5f1
to
fcaf759
Compare
time.Sleep(time.Second * 5) // wait for a few seconds so that timer is ready to be skipped | ||
req3 := apiClient.DefaultApi.ApiV1WorkflowTimerSkipPost(context.Background()) |
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 would work, but I usually prefer signal which is more controllable than time
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.
Simplified this test and removed the command entirely
32f62c9
to
d504521
Compare
Add comments addressed. Moving on to #454 |
Description
Checklist
Related Issue
Closes #411