From 8c20d6e2fe0064673ae9e7f3445116a44d03d2a6 Mon Sep 17 00:00:00 2001 From: Tamo Date: Wed, 9 Aug 2023 17:23:13 +0200 Subject: [PATCH] fix the leader election --- index-scheduler/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index-scheduler/src/lib.rs b/index-scheduler/src/lib.rs index 36f12dc25..c19a005ed 100644 --- a/index-scheduler/src/lib.rs +++ b/index-scheduler/src/lib.rs @@ -596,7 +596,8 @@ impl IndexScheduler { let (_stat, id) = zk.create("/election/node-", &[], &options).await.unwrap(); self_node_id = id; let previous_path = { - let list = zk.list_children("/election").await.unwrap(); + let mut list = zk.list_children("/election").await.unwrap(); + list.sort(); let self_node_path = format!("node-{}", self_node_id); let previous_path = @@ -629,7 +630,8 @@ impl IndexScheduler { zk::EventType::NodeDeleted => { let zk = zk.as_ref().unwrap(); let previous_path = { - let list = zk.list_children("/election").await.unwrap(); + let mut list = zk.list_children("/election").await.unwrap(); + list.sort(); let self_node_path = format!("node-{}", self_node_id); let previous_path =