Clarification on watch

The wiki page has a good explanation on watch: [1].

I still have some questions to clarify:

  1. Say DB has k1=v1; Client registers a watch on key k1; Later when the key is updated with the same value, say set(k1,v1), will the watch be triggered?
    (It seems the watch will be triggered based on

  2. If a shard is moved, will the watch inside the shared be triggered?
    I think so because the key will be removed from the storage server as a part of shard movement. This will change the StorageServer->watches;

  3. In the wiki page, it says

Watches are subjected to the ABA-problem: if a value changes twice and after the second update it has the same value as before, the client might not be notified of that update.

Question: This only happens when a watch is registered after the second update. If the watch registration happens before B is applied, the watch will be triggered. Right?

  1. The value of the watch will be checked after that trigger, and if it hasn’t changed the watch won’t fire.

  2. I think this gets bounced out to the client and probably automatically sent to the new location.

  3. I believe this can happen even if the watch is registered before any update, or at least it is allowed by contract.

1 Like

Yeah, you are right. I checked the code again. :slight_smile:

About 2., the watch will be triggered and try to register in the SS, which will throw the wrong_shard_server() error. The error is bounced back to the client (in and register the watch from the client.

About 3., because of the reason in 1, if the checking happens later after ABA is executed, then the watch will not be triggered.