-
Notifications
You must be signed in to change notification settings - Fork 911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change update namespace to upsert custom search attributes #4080
Conversation
9669784
to
cabac62
Compare
4892c3e
to
ed674da
Compare
ed674da
to
7926cf4
Compare
} else if _, ok := current[key]; !ok { | ||
result[key] = value | ||
} else { | ||
return nil, serviceerror.NewInvalidArgument( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm ask user to retry invalid argument looks weird.
Currently if there're concurrent namespace update, persistence layer will return Unavailable, which will be retried and customer most likely won't see the error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this Unavailable error retry is in the grpc level, which won't work because the args will be the same from the operator handler.
The retry from the user will make operator handler to generate a new map to be upsert based on newer version of the namespace data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If user must change agrs, then InvalidArgument
is the right error. Message should be different though. Don't use word "retry" there and explicitly say that specific argument must be changed.
@@ -280,18 +277,22 @@ func (h *OperatorHandlerImpl) addSearchAttributesSQL( | |||
if nsName == "" { | |||
return errNamespaceNotSet | |||
} | |||
ns, err := h.namespaceRegistry.GetNamespace(namespace.Name(nsName)) | |||
resp, err := client.DescribeNamespace( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this to avoid cache? Why not to call DescribeNamesapce
from namespace handler directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's to avoid cache. Namespace handler is not available in this context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be added, but ok, let's leave it this way.
} else if _, ok := current[key]; !ok { | ||
result[key] = value | ||
} else { | ||
return nil, serviceerror.NewInvalidArgument( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If user must change agrs, then InvalidArgument
is the right error. Message should be different though. Don't use word "retry" there and explicitly say that specific argument must be changed.
7926cf4
to
db45583
Compare
db45583
to
8e47773
Compare
Updated the operator/admin handler to return |
8e47773
to
84c4045
Compare
}, | ||
}) | ||
if err.Error() == errCustomSearchAttributeFieldAlreadyAllocated.Error() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ugly. But I don't see a better way :-(
@@ -280,18 +277,22 @@ func (h *OperatorHandlerImpl) addSearchAttributesSQL( | |||
if nsName == "" { | |||
return errNamespaceNotSet | |||
} | |||
ns, err := h.namespaceRegistry.GetNamespace(namespace.Name(nsName)) | |||
resp, err := client.DescribeNamespace( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be added, but ok, let's leave it this way.
What changed?
DescribeNamespace
API: it fetches from persistence instead of cache.UpdateNamespace
to upsert the custom search attributes field to alias map instead of simply overwriting the entire map. If the value is an empty string (ie., the alias is an empty string), then remove the alias.Why?
UpdateNamespace
ensures that concurrent calls to add search attributes are handled correctly without racing condition.How did you test it?
Started Server, and sent multiple calls to create search attribute using
tctl
and Temporal CLI. Verified that all search attributes were created correctly.Potential risks
No risks.
Is hotfix candidate?
No.