You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@zookeeper.apache.org by kamel zaarouri <ka...@gmail.com> on 2015/10/31 20:54:26 UTC

Can I receive out of order messages from zookeeper in these specific example?

I will present here two scenarios:

**Scenario 1:**

Assuming I have the following tree

    parent
           |____ child

And 2 clients A and B.

- Assume `B` is listening on changes of `child` and `parent`
- `A` updates `child` once and then updates `parent` once

Can `B` see changes of `parent` before seeing the changes of `child`?


**Scenario 2**

Assuming I have the following tree

    parent
           |____ child_1
           |____ child_2

If we have 3 clients `A`, `B` and `C` watching on changes from the children
of `parent` node. if client `A` received a callback that `child_1` has
changed and is about to update `child_2`. Can I safely assume that all the
clients `A`, `B` and `C` have already seen changes on `child_1` before
seeing the changes on `child_2`?

Would you be able to give me examples on when the above could fail please?

Thanks much,

Re: Can I receive out of order messages from zookeeper in these specific example?

Posted by Raúl Gutiérrez Segalés <rg...@itevenworks.net>.
On 31 October 2015 at 12:54, kamel zaarouri <ka...@gmail.com>
wrote:

> I will present here two scenarios:
>
> **Scenario 1:**
>
> Assuming I have the following tree
>
>     parent
>            |____ child
>
> And 2 clients A and B.
>
> - Assume `B` is listening on changes of `child` and `parent`
> - `A` updates `child` once and then updates `parent` once
>
> Can `B` see changes of `parent` before seeing the changes of `child`?
>

It cannot, all writes are serialized which means that dispatching watches
are
serialized as well. So unless there's a bug in the client application with
how watchers
are called the should see thing in order.


>
>
> **Scenario 2**
>
> Assuming I have the following tree
>
>     parent
>            |____ child_1
>            |____ child_2
>
> If we have 3 clients `A`, `B` and `C` watching on changes from the children
> of `parent` node. if client `A` received a callback that `child_1` has
> changed and is about to update `child_2`. Can I safely assume that all the
> clients `A`, `B` and `C` have already seen changes on `child_1` before
> seeing the changes on `child_2`?
>

Yeah same thing, watches will be delivered in order. What you actually
see depends on when you issue the corresponding reads.

Btw, when I had to debug similar things before I've used zk-dump [0] to
see watches being delivered (and to make sure things are in order).


-rgs

[0] https://github.com/twitter/zktraffic