[sheepdog] [PATCH v2 1/2] sheep/cluster: use wrapper function to create ephemeral znode
Liu Yuan
namei.unix at gmail.com
Mon Mar 3 09:30:14 CET 2014
On Mon, Mar 03, 2014 at 04:02:34PM +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>
> ---
> v1-->v2:
> 1. fix a compile warning
>
> sheep/cluster/zookeeper.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c
> index 3c812c1..8cdcf84 100644
> --- a/sheep/cluster/zookeeper.c
> +++ b/sheep/cluster/zookeeper.c
> @@ -1271,7 +1271,6 @@ kick_block_event:
> */
> static void zk_lock(uint64_t lock_id)
> {
> - int flags = ZOO_SEQUENCE | ZOO_EPHEMERAL;
> int rc, len = MAX_NODE_STR_LEN;
> char *my_path;
> char parent[MAX_NODE_STR_LEN];
> @@ -1295,9 +1294,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
Applied these two, thanks
Yuan
More information about the sheepdog
mailing list