mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-04 18:45:46 +01:00
fix the leader election
This commit is contained in:
parent
d1bc7ec58a
commit
41178e59fc
@ -474,6 +474,8 @@ impl IndexScheduler {
|
|||||||
|
|
||||||
let string_id = id.to_string();
|
let string_id = id.to_string();
|
||||||
|
|
||||||
|
log::info!("Entering the election game with the ID: {id}");
|
||||||
|
|
||||||
// there is at least us in the childrens of election
|
// there is at least us in the childrens of election
|
||||||
if childrens[0].ends_with(&string_id) {
|
if childrens[0].ends_with(&string_id) {
|
||||||
log::warn!("I'm the leader");
|
log::warn!("I'm the leader");
|
||||||
@ -483,7 +485,7 @@ impl IndexScheduler {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.rfind(|path| &path[path.len() - string_id.len()..] < string_id.as_str())
|
.rfind(|path| &path[path.len() - string_id.len()..] < string_id.as_str())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
log::warn!("I'm a follower When `{should_watch}` die I should check if I'm the new leader");
|
log::warn!("I'm a follower. When `{should_watch}` die I should check if I'm the new leader");
|
||||||
|
|
||||||
let leader_watcher = zk
|
let leader_watcher = zk
|
||||||
.watch(&format!("/election/{should_watch}"), AddWatchMode::Persistent)
|
.watch(&format!("/election/{should_watch}"), AddWatchMode::Persistent)
|
||||||
@ -524,8 +526,13 @@ impl IndexScheduler {
|
|||||||
.rfind(|path| &path[path.len() - id.len()..] < id.as_str())
|
.rfind(|path| &path[path.len() - id.len()..] < id.as_str())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let watcher =
|
log::warn!("Watching {should_watch} for now");
|
||||||
zk.watch(&should_watch, AddWatchMode::Persistent).unwrap();
|
let watcher = zk
|
||||||
|
.watch(
|
||||||
|
&format!("/election/{}", should_watch),
|
||||||
|
AddWatchMode::Persistent,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
watchers.replace(event, watcher).unwrap();
|
watchers.replace(event, watcher).unwrap();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user