From c5ec817f526d8af89043653d18193e8fd452a882 Mon Sep 17 00:00:00 2001 From: Tamo Date: Thu, 2 Nov 2023 18:21:17 +0100 Subject: [PATCH] WIP fix a lot of bugs: The follower do not wake up when a new snapshot is available --- index-scheduler/src/lib.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/index-scheduler/src/lib.rs b/index-scheduler/src/lib.rs index 169f963c4..0764be428 100644 --- a/index-scheduler/src/lib.rs +++ b/index-scheduler/src/lib.rs @@ -502,10 +502,13 @@ impl IndexScheduler { thread::spawn(move || { loop { if let Some((zk, id, watchers)) = &mut clusterized { + log::info!("Waiting for an event to happen as a follower"); // We're a follower + // TODO: TAMO: the watchers never changes, that's not normal let event = watchers.changed(); + log::info!("Woke up, we got a new event at {}", event.path); - if event.path.starts_with("election") { + if event.path.starts_with("/election") { if event.event_type == EventType::NodeDeleted { // The person we were following died, we must see if we're the new leader let (mut childrens, _) = zk.get_children("/election").unwrap(); @@ -580,7 +583,8 @@ impl IndexScheduler { .create( "/snapshots/snapshot-", &[], - &CreateMode::Persistent.with_acls(Acls::anyone_all()), + &CreateMode::PersistentSequential + .with_acls(Acls::anyone_all()), ) .unwrap(); @@ -1457,7 +1461,7 @@ impl IndexSchedulerInner { match zookeeper.create( "/tasks/task-", &[], - &CreateMode::Persistent.with_acls(Acls::anyone_all()), + &CreateMode::PersistentSequential.with_acls(Acls::anyone_all()), ) { Ok((_, id)) => Some(id), Err(e) => panic!("{e}"),