zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Flavio Junqueira <...@apache.org>
Subject Re: Can a CRUD operation succeed when we have a ConnectionLossException?
Date Fri, 02 Oct 2015 16:59:29 GMT
The behavior is expected. If your client loses its connection, then you don't know if the operation
has gone through or not. When it reconnects, you can check if it exists and possibly delete
it, depending on the behavior you want for you application. 

-Flavio

> On 02 Oct 2015, at 17:48, Benjamin Jaton <benjamin.jaton@gmail.com> wrote:
> 
> Hi,
> 
> In a small test class I keep creating/deleting the same node /test.
> 
> I kill (Ctrl+C) and restart the ZK server in the command line randomly.
> 
> After a couple attempts here is what we get:
> 
> Fri Oct 02 09:27:23 PDT 2015 - Deleting /test
> Fri Oct 02 09:27:23 PDT 2015 - /test has been deleted.
> Fri Oct 02 09:27:23 PDT 2015 - Node /test has successfully been removed.
> Fri Oct 02 09:27:23 PDT 2015 - Recreating /test
> Fri Oct 02 09:27:23 PDT 2015 - CONN LOST on create
> Fri Oct 02 09:27:24 PDT 2015 - ERROR: node should be removed.
> Fri Oct 02 09:27:24 PDT 2015 - Data of node is: test
> Node has been mysteriously created...
> org.apache.zookeeper.KeeperException$NodeExistsException: KeeperErrorCode = NodeExists
for /test
>     at org.apache.zookeeper.KeeperException.create(KeeperException.java:123)
>     at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
>     at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1209)
>     at TestZKSaveConnLoss.create(TestZKSaveConnLoss.java:101)
>     at TestZKSaveConnLoss.access$4(TestZKSaveConnLoss.java:98)
>     at TestZKSaveConnLoss$2.run(TestZKSaveConnLoss.java:56)
> 
> The 1st create fails with a ConnectionLossException.
> When we retry to create the node, we get a NodeExistsException.
> 
> So the node got created despite the ConnectionLossException.
> The same thing happens with the delete operation.
> 
> I was wondering if this is an known/expected behavior and how people deal with it?
> 
> Thanks,
> Ben
> 
> 
> Original issue reported at: https://issues.apache.org/jira/browse/CURATOR-268 <https://issues.apache.org/jira/browse/CURATOR-268>
> <TestZKSaveConnLoss.java>


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