[sheepdog] [PATCH v1 1/2] sheep/cluster: use wrapper function to create ephemeral znode

Liu Yuan namei.unix at gmail.com
Fri Feb 28 10:22:38 CET 2014


On Fri, Feb 28, 2014 at 02:47:52PM +0800, Robin Dong wrote:
> From: Robin Dong <sanbai at taobao.com>
> 
> We use zk_create_node() before, but when operation of creating ephemeral
> zonde has been timeout, we will see multi-znodes in parent znode because
> zk_create_node() will create znodes again if there is ZOPERATIONTIMEOUT.
> Multi-znodes in same directry will make zk_lock() be dead loop.
> 
> The best solution for this problem is make value of 'timeout' for
> zookeeper_init() bigger, but we still need to use zk_create_seq_node() to
> replace zk_create_node() for which we will see "operation timeout" fail
> in sheep log.
> 
> Signed-off-by: Robin Dong <sanbai at taobao.com>
> ---
>  sheep/cluster/zookeeper.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c
> index 3c812c1..1fa36ee 100644
> --- a/sheep/cluster/zookeeper.c
> +++ b/sheep/cluster/zookeeper.c
> @@ -1295,9 +1295,9 @@ static void zk_lock(uint64_t lock_id)
>  create_seq_node:
>  	/* compete owner of lock is just like zk_compete_master() */
>  	while (true) {
> -		rc = zk_create_node(parent, node_to_str(&this_node.node),
> -				    MAX_NODE_STR_LEN, &ZOO_OPEN_ACL_UNSAFE,
> -				    flags, my_path, MAX_NODE_STR_LEN);
> +		rc = zk_create_seq_node(parent, node_to_str(&this_node.node),
> +					MAX_NODE_STR_LEN, my_path,
> +					MAX_NODE_STR_LEN, true);
>  		if (rc == ZOK)
>  			break;
>  		if (rc == ZNONODE) {
> -- 
> 1.7.12.4
> 
> -- 
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog

Compile error

cluster/zookeeper.c: In function ‘zk_lock’:
cluster/zookeeper.c:1274:6: warning: unused variable ‘flags’ [-Wunused-variable]
  int flags = ZOO_SEQUENCE | ZOO_EPHEMERAL;

Thanks
Yuan



More information about the sheepdog mailing list