Skip to content

Commit 654bc3f

Browse files
authored
Fix create custom search attribute with SQL DB (#3951)
1 parent 677890b commit 654bc3f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

service/frontend/operator_handler.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ func (h *OperatorHandlerImpl) addSearchAttributesSQL(
285285
return serviceerror.NewUnavailable(fmt.Sprintf(errUnableToGetNamespaceInfoMessage, nsName))
286286
}
287287

288-
customSearchAttributes := currentSearchAttributes.Custom()
288+
dbCustomSearchAttributes := searchattribute.GetSqlDbIndexSearchAttributes().CustomSearchAttributes
289+
cmCustomSearchAttributes := currentSearchAttributes.Custom()
289290
mapper := ns.CustomSearchAttributesMapper()
290291
fieldToAliasMap := util.CloneMapNonNil(mapper.FieldToAliasMap())
291292
for saName, saType := range request.GetSearchAttributes() {
@@ -298,10 +299,14 @@ func (h *OperatorHandlerImpl) addSearchAttributesSQL(
298299
// find the first available field for the given type
299300
targetFieldName := ""
300301
cntUsed := 0
301-
for fieldName, fieldType := range customSearchAttributes {
302+
for fieldName, fieldType := range dbCustomSearchAttributes {
302303
if fieldType != saType {
303304
continue
304305
}
306+
// make sure the pre-allocated custom search attributes are created in cluster metadata
307+
if _, ok := cmCustomSearchAttributes[fieldName]; !ok {
308+
continue
309+
}
305310
if _, ok := fieldToAliasMap[fieldName]; !ok {
306311
targetFieldName = fieldName
307312
break

0 commit comments

Comments
 (0)