You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by "zhaohaidao (via GitHub)" <gi...@apache.org> on 2023/09/16 18:03:32 UTC
[GitHub] [zookeeper] zhaohaidao commented on a diff in pull request #2064: ZOOKEEPER-4743: Jump from 2 to 0 when zookeeper dataVersion incre
zhaohaidao commented on code in PR #2064:
URL: https://github.com/apache/zookeeper/pull/2064#discussion_r1327992417
##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/PrepRequestProcessor.java:
##########
@@ -735,10 +735,18 @@ private String getParentPathAndValidate(String path) throws BadArgumentsExceptio
}
private static int checkAndIncVersion(int currentVersion, int expectedVersion, String path) throws KeeperException.BadVersionException {
- if (expectedVersion != -1 && expectedVersion != currentVersion) {
- throw new KeeperException.BadVersionException(path);
+ if (expectedVersion != -1) {
+ if (expectedVersion != currentVersion) {
+ throw new KeeperException.BadVersionException(path);
+ }
+ if (expectedVersion == -2) {
+ return 0;
+ } else {
+ return currentVersion + 1;
+ }
+ } else {
+ return currentVersion + 1;
Review Comment:
Hey. @kezhuw Thanks for your suggestion. Can you explain it further? The current approach is to be as consistent as possible with the existing semantics of zookeeper, that is, except expectedVersion which is -1, all other values need to be checked for equality.
So my question is why should we skip this check when it is -2?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org