Skip to content

Redundant updateValue call in SharedValue? #1254

Closed

Description

@ryansun96

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?

Activity

  1. tisonkun commented on Mar 18, 2025

    @tisonkun
    Member

    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.

  2. kezhuw commented on Mar 19, 2025

    @kezhuw
    Member

    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.

  3. ryansun96 commented on Mar 20, 2025

    @ryansun96
    Author

    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

  4. kezhuw commented on Mar 22, 2025

    @kezhuw
    Member

    If that's the intention, it should be documented, as in the case of trySetValue:

    Absolutely right! Look forward your contribution if you are willing to do so!

  5. added a commit that references this issue on Apr 7, 2025
    890d70a
  6. added a commit that references this issue on Apr 8, 2025
    1bd8450
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions