Skip to content

Commit

Permalink
Merge branch 'master' into eager-workflow-dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
bergundy authored Feb 1, 2023
2 parents f23a706 + af00719 commit 16445ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
15 changes: 10 additions & 5 deletions common/searchattribute/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (

enumspb "go.temporal.io/api/enums/v1"
"go.temporal.io/api/serviceerror"
"golang.org/x/exp/maps"

persistencespb "go.temporal.io/server/api/persistence/v1"
"go.temporal.io/server/common/clock"
Expand Down Expand Up @@ -110,20 +111,24 @@ func (m *managerImpl) GetSearchAttributes(
m.cacheUpdateMutex.Unlock()
}

result := NameTypeMap{}
indexSearchAttributes, ok := saCache.searchAttributes[indexName]
if ok {
return indexSearchAttributes, nil
result.customSearchAttributes = maps.Clone(indexSearchAttributes.customSearchAttributes)
}

// TODO (rodrigozhou): remove following block for v1.21.
// Try to look for the empty string indexName for backward compatibility: up to v1.19,
// empty string was used when Elasticsearch was not configured.
// If there's a value, merging with current index name value. This is to avoid handling
// all code references to GetSearchAttributes.
if indexName != "" {
// Try to look for the empty string indexName for backward compatibility: up to v1.19,
// empty string was used when Elasticsearch was not configured.
indexSearchAttributes, ok = saCache.searchAttributes[""]
if ok {
return indexSearchAttributes, nil
maps.Copy(result.customSearchAttributes, indexSearchAttributes.customSearchAttributes)
}
}
return NameTypeMap{}, nil
return result, nil
}

func (m *managerImpl) needRefreshCache(saCache cache, forceRefreshCache bool, now time.Time) bool {
Expand Down
7 changes: 0 additions & 7 deletions common/searchattribute/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ func (v *Validator) Validate(searchAttributes *commonpb.SearchAttributes, namesp
)
}

// TODO (rodrigozhou): this is to be backwards compatible with custom search attributes
// registered before v1.20. Ignoring error as this key might not exist.
emptyStringSaTypeMap, _ := v.searchAttributesProvider.GetSearchAttributes("", false)

for saFieldName, saPayload := range searchAttributes.GetIndexedFields() {
// user search attribute cannot be a system search attribute
if _, err = saTypeMap.getType(saFieldName, systemCategory); err == nil {
Expand All @@ -105,9 +101,6 @@ func (v *Validator) Validate(searchAttributes *commonpb.SearchAttributes, namesp
}

saType, err := saTypeMap.getType(saFieldName, customCategory|predefinedCategory)
if err != nil {
saType, err = emptyStringSaTypeMap.getType(saFieldName, customCategory)
}
if err != nil {
if errors.Is(err, ErrInvalidName) {
return v.validationError(
Expand Down

0 comments on commit 16445ad

Please sign in to comment.