Skip to content

Commit

Permalink
Do not generate visibility task for unchanged BuildIds (#4632)
Browse files Browse the repository at this point in the history
**What changed?**
Do not generate a visibility task for updating BuildIds if it's
unchanged.

**Why?**
Excess visibility tasks.

**How did you test it?**
will add unit tests

**Potential risks**


**Is hotfix candidate?**
  • Loading branch information
dnr authored and mindaugasrukas committed Jul 14, 2023
1 parent c61ede4 commit 9219be2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions service/history/workflow/mutable_state_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1902,7 +1902,7 @@ func (ms *MutableStateImpl) ReplicateWorkflowExecutionStartedEvent(
}
if event.SourceVersionStamp.GetUseVersioning() && event.SourceVersionStamp.GetBuildId() != "" {
limit := ms.config.SearchAttributesSizeOfValueLimit(string(ms.namespaceEntry.Name()))
if err := ms.addBuildIdsWithNoVisibilityTask([]string{worker_versioning.VersionedBuildIdSearchAttribute(event.SourceVersionStamp.BuildId)}, limit); err != nil {
if _, err := ms.addBuildIdsWithNoVisibilityTask([]string{worker_versioning.VersionedBuildIdSearchAttribute(event.SourceVersionStamp.BuildId)}, limit); err != nil {
return err
}
}
Expand Down Expand Up @@ -2107,8 +2107,10 @@ func (ms *MutableStateImpl) trackBuildIdFromCompletion(
if len(toAdd) == 0 {
return nil
}
if err := ms.addBuildIdsWithNoVisibilityTask(toAdd, limits.MaxSearchAttributeValueSize); err != nil {
if changed, err := ms.addBuildIdsWithNoVisibilityTask(toAdd, limits.MaxSearchAttributeValueSize); err != nil {
return err
} else if !changed {
return nil
}
return ms.taskGenerator.GenerateUpsertVisibilityTask()
}
Expand Down Expand Up @@ -2185,16 +2187,16 @@ func (ms *MutableStateImpl) saveBuildIds(buildIds []string, maxSearchAttributeVa
return nil
}

func (ms *MutableStateImpl) addBuildIdsWithNoVisibilityTask(buildIds []string, maxSearchAttributeValueSize int) error {
func (ms *MutableStateImpl) addBuildIdsWithNoVisibilityTask(buildIds []string, maxSearchAttributeValueSize int) (bool, error) {
existingBuildIds, err := ms.loadBuildIds()
if err != nil {
return err
return false, err
}
modifiedBuildIds, added := ms.addBuildIdToLoadedSearchAttribute(existingBuildIds, buildIds)
if !added {
return nil
return false, nil
}
return ms.saveBuildIds(modifiedBuildIds, maxSearchAttributeValueSize)
return true, ms.saveBuildIds(modifiedBuildIds, maxSearchAttributeValueSize)
}

// TODO: we will release the restriction when reset API allow those pending
Expand Down

0 comments on commit 9219be2

Please sign in to comment.