-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[pulsar-metadata] return alreadyExist error-code when node exists #9501
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
Conversation
eolivelli
left a comment
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.
LGTM
| } else if (code == Code.NODEEXISTS) { | ||
| // We're emulating a request to create node, so the version is invalid | ||
| future.completeExceptionally(getException(Code.BADVERSION, path)); | ||
| future.completeExceptionally(getException(Code.NODEEXISTS, path)); |
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 was done on purpose here. Since there is no "create()" operation but just the put() with the optional expected version. A create() is equivalent to a put(Optional.of(-1)) (eg: expecting the node not to be there). In that light it makes sense to me to stick to the BadVersion.
If the caller wants to make sure to create an entry, it just need to treat the bad version error for what it is: the state it's not what was expected.
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.
we can handle BADVERSION as NODEEXISTS at caller side. but my only concern was what exact benefit we can get by returning different error-code. because actual error (in this case AlreadyExist) can help better in handling failure rather than deriving from BADVERSION . I will try to change handling at caller side but I think we might have usecases in future to explicitly know specific error to handle the failure.
In this specific case, you're trying to create an entry. If you do |
eolivelli
left a comment
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.
I agree with @merlimat 's comment.
In fact there was a comment explaining the reason of the BADVERSION code.
the weird fact is that ZK API returns a NODEEXISTS error.
We are abstracting from ZK API, so we can have our own behaviour.
Motivation
Right now, MetadataStore returns
BadVersionerror when node already exists insteadAlreadyExistserror-code. There are many usecases which require correct error code to handle failures. for example: partitioned-topic considersAlreadyExistserror as successful result but instead metadata-api returnsBadVersionerror which creates complication while handling failures.So, return correct error-code(
AlreadyExists) if node already exists while creating metadata key-placeholder,