[sheepdog] [PATCH] zookeeper: fix bug when update queue_pos

Meng Lingkun menglingkun at cmss.chinamobile.com
Wed Mar 11 16:26:45 CET 2015


The znode of a sheep(queue_pos/$sheep_id) in queue_pos will be created
after the sheep is accept. However, if the znode's seq in queue with
type EVENT_ACCEPT % DEL_QUEUE_BATCH == 0, zookeeper driver will update
the queue_pos/$sheep_id before queue_pos/$sheep_id is created. So fix it.

Signed-off-by: Meng Lingkun <menglingkun at cmss.chinamobile.com>
---
 sheep/cluster/zookeeper.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c
index b346592..303449e 100644
--- a/sheep/cluster/zookeeper.c
+++ b/sheep/cluster/zookeeper.c
@@ -591,7 +591,8 @@ static int zk_queue_pop_advance(struct zk_event *ev)
 	sd_debug("%s, type:%d, len:%d, pos:%" PRId32, path, ev->type, len,
 		 queue_pos);
 
-	if (queue_pos % QUEUE_DEL_BATCH == 0 && ev->type != EVENT_JOIN) {
+	if (queue_pos % QUEUE_DEL_BATCH == 0 && ev->type != EVENT_JOIN
+		&& ev->type != EVENT_ACCEPT) {
 		snprintf(queue_pos_path, sizeof(queue_pos_path),
 			QUEUE_POS_ZNODE"/%s", node_to_str(&this_node.node));
 		RETURN_IF_ERROR(zk_set_data(queue_pos_path, (char *)&queue_pos,
-- 
1.7.1






More information about the sheepdog mailing list