[sheepdog] [PATCH stable-0.8 5/6] sheep/cluster: use wrapper function to create ephemeral znode

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Tue Mar 18 07:30:58 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>
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 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.8.1.2




More information about the sheepdog mailing list