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

Robin Dong robin.k.dong at gmail.com
Fri Feb 28 07:47:52 CET 2014


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




More information about the sheepdog mailing list