zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kishore g <g.kish...@gmail.com>
Subject Re: Behavior when client disconnects
Date Thu, 05 Dec 2013 04:50:53 GMT
Thanks Camille, Is it not violating the assumption that a client reads its
own write (probably its ok in this case because client never got the ack
for write from server)

Consider the following simple code where one wants to know if something was
successfully written.

boolean success;
try{
  zk.write(p)
  success= true;
}catch(Exception e)
{
  //cannot assume write did not go through
  //read the value and see if you really wrote it
  success = zk.exists(p) && zk.readStat(p).owner == me
}

Looks like if the connection breaks at zk.write(p), success can either be
true or false. Probably the only way to make sure write was successful is
try writing again when there is exception.

Does this make sense?

thanks,
Kishore G







On Wed, Dec 4, 2013 at 6:12 PM, Camille Fournier <camille@apache.org> wrote:

> As far as I can tell from the code:
> c1 will send its last seen zxid to the server that it is trying to connect
> to. If that zxid is greater than the zxid of the server, the server will
> refuse the connection. In this case, if the client has not seen an ack, it
> is certainly possible that the last zxid seen will be the same as the zxid
> of the server it is connected to, so it will not see the result of w1 yet.
>
> C
>
>
> On Wed, Dec 4, 2013 at 3:37 PM, kishore g <g.kishore@gmail.com> wrote:
>
> > Hi,
> >
> > Consider the following case
> >
> >
> >    1. Client c1 sends a write(w1) to zk1
> >    2. w1 gets ack from zk2 but not yet from zk3, but quorum is reached
> >    3. By the time zk1 sends response back to c1, the connection breaks
> >    4. c1 did not get the zxid for the latest transaction
> >
> > Now c1, depending on whether it connects to zk2 or zk3 might see that w1
> > was successful or failure.  Is this analysis correct or will c1
> > automatically invoke a sync under the hoods when it gets disconnected and
> > connected to another server?
> >
> > If no, how should one handle this scenario.
> > Thanks,
> > Kishore G
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message