kezhuw commented on code in PR #478:
URL: https://github.com/apache/curator/pull/478#discussion_r1313839760
##########
curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java:
##########
@@ -196,8 +196,12 @@ public boolean trySetValue(VersionedValue<byte[]>
previous, byte[] newValue) thr
private void updateValue(int version, byte[] bytes) {
while (true) {
VersionedValue<byte[]> current = currentValue.get();
- if (current.getVersion() >= version) {
- // A newer version was concurrently set.
Review Comment:
I am not sure wether `SharedValue` was designed to work with multiple
owners, but I saw there is a background watcher to update value and also there
is no rule to forbid concurrent usages. So, I assume it should work well in
case of concurrency.
Then, let me assume a situation:
1. `current.getVersion` is `Integer.MAX_VALUE`.
2. Thread1 call `trySetValue` and succeed to get overflowed version
`Integer.MIN_VALUE`, but the call to `updateValue` is somewhat delayed.
3. Thread2 (assume watcher, which runs in ZooKeeper thread if I am not
wrong) call `updateVersion` with version `Integer.MIN_VALUE + 1`. According to
the code, this will be ignored.
4. Thread1 call `updateValue` to continue its task with version
`Integer.MIN_VALUE`. It succeeds.
5. That is all, assume no changes anymore. I know it may not realistic.
`current` stores dated version while the javadoc says "All clients watching
the same path will have the up-to-date value (considering ZK's normal
consistency guarantees)".
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]