[sheepdog] [PATCH v3 2/2] sheep/cluster: re-create znode of 'lock-id' if it isn't exists
Robin Dong
robin.k.dong at gmail.com
Sun Jan 19 14:02:00 CET 2014
2014/1/19 Liu Yuan <namei.unix at gmail.com>
> On Sun, Jan 19, 2014 at 08:52:59PM +0800, Robin Dong wrote:
> > From: Robin Dong <sanbai at taobao.com>
> >
> > When a sheep daemon call zk_unlock(), it will remove the whole znode of
> 'lock-id' and
> > make zoo_create() fail in zk_lock() which called by another sheep daemon.
> > To avoid this, we should try to create a znode of 'lock-id' if
> zoo_create() fail.
> >
> > Signed-off-by: Robin Dong <sanbai at taobao.com>
> > ---
> > sheep/cluster/zookeeper.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c
> > index ad5a9af..4527db1 100644
> > --- a/sheep/cluster/zookeeper.c
> > +++ b/sheep/cluster/zookeeper.c
> > @@ -1256,6 +1256,10 @@ static void zk_lock(uint64_t lock_id)
> > flags, my_path, MAX_NODE_STR_LEN);
> > if (rc == ZOK)
> > break;
> > + if (rc == ZNONODE) {
> > + zk_init_node(parent);
>
> Should check error of zk_init_node and handle it.
>
No matter whatever error the zk_init_node() return, we only have to
"continue" in zk_lock()
>
> Thanks
> Yuan
>
--
--
Best Regard
Robin Dong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wpkg.org/pipermail/sheepdog/attachments/20140119/352d0b90/attachment-0004.html>
More information about the sheepdog
mailing list