diff --git a/service/history/workflow/mutable_state_impl.go b/service/history/workflow/mutable_state_impl.go index c307dc1899c..5db75e2a7b9 100644 --- a/service/history/workflow/mutable_state_impl.go +++ b/service/history/workflow/mutable_state_impl.go @@ -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 } } @@ -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() } @@ -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