In my understanding, Zookeeper doesn't guarantee to return the newest value, because a client may be connecting to a server that doesn't receive the newest update request.
Let's suppose that if I use one client and three servers, for example, client M, server {A, B, C}, and A becomes a leader, B, C become followers. I think this is what may happen below:
- znode z has value "zero".
- M connects to server C (follower)
- M set znode z to "one".
- C send request (setData z "one") to A, which is a leader.
- M is waiting for success, then A and B successfully set node z to "one".
- M getData z, then C returns value "zero" to M. (just read local)
- C successfully set node z to "one".
- M getData z again, then get "one" from C.
Then M data will have a "backward", M write "one" then read "zero".
My questions is:
- Is my description about what zookeeper actually works correct? I mean the same client can write "one" but read "zero".
- If one client can write "one" and must read "one" after writing, how can Zookeeper do that?