You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In SharedValue.setValue(byte[] newValue), updateValue is called after the value on zookeeper is set. Is this redundant considering that SharedValue already has watcher that will update local value on remote change?
Is this redundant considering that SharedValue already has watcher that will update local value on remote change?
I think setValue make a strong guarantee after success, the getValue will observe that value if update is success. Asynchronous watcher is not capable of this.
guarantee... the getValue will observe that value if update is success
However getValue is not / cannot be guaranteed to observe that value even with a blocking update call, in the event that another set has occurred in a different session, and the asynchronous watcher updates local value before getValue is executed.
I think it's fair to say setValue makes a strong guarantee that after success, any call to getValue will get some more updated value, whether that value is set by the same session or a different one cannot be guaranteed though.
If that's the intention, it should be documented, as in the case of trySetValue:
If the value has changed, the value is not set and this client's view of the value is updated. i.e. if the value is not successful you can get the updated value by calling {@link #getValue()}.
Whereas currently there's no mention of such in the doc of setValue:
Change the shared value irrespective of its previous state
Activity
tisonkun commentedon Mar 18, 2025
IIRC this is modified in #478 where we try to fix a bug in SharedValue.
cc @kezhuw @Hexiaoqiao if you have the related context. I don't remember it quite clearly now.
kezhuw commentedon Mar 19, 2025
I think
setValuemake a strong guarantee after success, thegetValuewill observe that value if update is success. Asynchronous watcher is not capable of this.ryansun96 commentedon Mar 20, 2025
However
getValueis not / cannot be guaranteed to observe that value even with a blockingupdatecall, in the event that anothersethas occurred in a different session, and the asynchronous watcher updates local value beforegetValueis executed.I think it's fair to say
setValuemakes a strong guarantee that after success, any call togetValuewill get some more updated value, whether that value is set by the same session or a different one cannot be guaranteed though.If that's the intention, it should be documented, as in the case of
trySetValue:Whereas currently there's no mention of such in the doc of
setValue:kezhuw commentedon Mar 22, 2025
Absolutely right! Look forward your contribution if you are willing to do so!
Document read effects after SharedValue.setValue
Document read effects after SharedValue.setValue (#1261)