Skip to content

Fix search attribute creation race#10057

Open
awln-temporal wants to merge 1 commit intomainfrom
add-search-attribute-race
Open

Fix search attribute creation race#10057
awln-temporal wants to merge 1 commit intomainfrom
add-search-attribute-race

Conversation

@awln-temporal
Copy link
Copy Markdown
Contributor

What changed?

Add check for duplicate aliases when registering search attributes in UpdateNamespace handler.

Why?

Registering search attributes through Operator handler checks for already registered aliases and fields, but this initial read has no checks for the version of the Namespace Config. UpdateNamespace handler does another read of the namespace config before attempting to write with the Config version as optimistic concurrency control, but this last validation only checks for competing field names. So, if a user registers the same search attribute alias at the same time, they can both be treated as valid updates, leading to undefined behavior when querying from visibility.

How did you test it?

  • built
  • run locally and tested manually
  • covered by existing tests
  • added new unit test(s)
  • added new functional test(s)

@awln-temporal awln-temporal requested review from a team as code owners April 24, 2026 19:10
@awln-temporal awln-temporal force-pushed the add-search-attribute-race branch from 357d7fa to ff40273 Compare April 24, 2026 19:27
@awln-temporal awln-temporal force-pushed the add-search-attribute-race branch from ff40273 to abd9609 Compare April 24, 2026 19:45
Comment on lines 954 to 963
} else if _, ok := current[key]; !ok {
if _, aliasExists := currentAliasToField[value]; aliasExists {
d.logger.Warn(
fmt.Sprintf(errSearchAttributeAlreadyExistsMessage, value),
tag.String("visibility-search-attribute", value),
)
continue
}
result[key] = value
} else {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
} else if _, ok := current[key]; !ok {
if _, aliasExists := currentAliasToField[value]; aliasExists {
d.logger.Warn(
fmt.Sprintf(errSearchAttributeAlreadyExistsMessage, value),
tag.String("visibility-search-attribute", value),
)
continue
}
result[key] = value
} else {
} else if _, aliasExists := currentAliasToField[value]; aliasExists {
d.logger.Warn(
fmt.Sprintf(errSearchAttributeAlreadyExistsMessage, value),
tag.String("visibility-search-attribute", value),
)
continue
} else if _, ok := current[key]; !ok {
result[key] = value
} else {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants