The wiki page has a good explanation on watch: An Overview how Watches Work · apple/foundationdb Wiki · GitHub [1].
I still have some questions to clarify:
-
Say DB has
k1=v1
; Client registers a watch on keyk1
; Later when the key is updated with the same value, sayset(k1,v1)
, will the watch be triggered?
(It seems the watch will be triggered based on https://github.com/apple/foundationdb/blob/master/fdbserver/storageserver.actor.cpp#L1891) -
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 theStorageServer->watches
; -
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?