Hi Andor,
Thanks for the response:
Below is the code snippet:
void
watcher(zhandle_t *zzh, int type, int state,
const char *path, void *ctx) {
check_path(ctx);
}
void check_path(void *ctx) {
struct String_vector children;
int rc = 0;
/* (1) get the current set of children for "/a" */
rc = zoo_wget_children(zh, “/a”, watcher, ctx, &children);
/* there are some children to “/a” */
if (children.count > 0) {
return;
}
/* (2) no children, try deleting “/a” */
rc = zoo_delete(“/a”, -1);
/* should not happen */
if (rc == ZNOTEMPTY) {
/* (3) get the current set of children for “/a” */
rc = zoo_wget_children(zh, “/a”, watcher, ctx, &children);
if (children.count == 0)
assert(); /* we hit this assert */
}
}
We have initiated watch of "/a" like below:
rc = zoo_wget_children(zh, “/a”, watcher, ctx, &children);
Is it possible that the delete of ephemeral nodes are not committed yet by the
Leader, hence a delete (2) will fail. While a read returns that there are no
nodes in (1) and (3) as the session have expired and the znode delete has been
initiated by Leader?
Thanks,
Pramod
On 5/2/18, 10:18 AM, "Andor Molnar" <[email protected]> wrote:
Hi Pramod,
I think you should be able to delete znode /a once both B and C sessions
are closed/expired and childrens are removed.
Would you please post relevant code snippets of your processes to get some
insight on what's happening?
Regards,
Andor
On Wed, May 2, 2018 at 7:11 PM Pramod Srinivasan <[email protected]> wrote:
> any thoughts on this?
>
> On 5/1/18, 1:43 PM, "Pramod Srinivasan" <[email protected]> wrote:
>
> Hello Everyone,
>
> Can someone help me rationalize the behavior I see?
>
> 1) Process A is watching node /a
> 2) Process B and Process C add ephemeral nodes, say /a/b and /a/c
> 3) Process B and Process C close their session and Process A gets a
> ZOO_CHILD_EVENT event when b and c goes away.
> 4) In the context of ZOO_CHILD_EVENT, Process A does a
> zoo_wget_children for “/a” and find its empty, but when it tries to delete
> “/a”, it finds that it is not empty and zoo_wget_children again returns no
> children.
>
> How can get_children return no children for a znode and a remove of
> the znode fail with not empty? It looks like there is a relation with
> ephemeral nodes and Follower/Leader behavior, don’t understand this enough
> to make sense
>
> Thanks,
> Pramod
>
>
>