From d0a3582a564f5e5a98bfd610418962f0f7638d05 Mon Sep 17 00:00:00 2001 From: Tamo Date: Thu, 2 Nov 2023 16:45:33 +0100 Subject: [PATCH] no deadlock on start --- Cargo.lock | 3 +-- Cargo.toml | 5 ++++- meilisearch-auth/src/lib.rs | 4 ++-- meilisearch/src/lib.rs | 2 +- meilisearch/src/main.rs | 4 +++- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b22640253..2218ff591 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4011,7 +4011,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "strois" version = "0.0.4" -source = "git+http://github.com/meilisearch/strois?rev=eeb945c#eeb945cfb6c666935b0f06b1f410fd83182b2b67" +source = "git+https://github.com/meilisearch/strois?rev=eeb945c#eeb945cfb6c666935b0f06b1f410fd83182b2b67" dependencies = [ "http", "log", @@ -4964,7 +4964,6 @@ dependencies = [ [[package]] name = "zookeeper-client-sync" version = "0.1.0" -source = "git+https://github.com/irevoire/zookeeper-client-sync.git#e781ad856d23b655c2c74d51833e04972e400207" dependencies = [ "futures", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index 3c613dc6f..5284eed39 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,4 +38,7 @@ opt-level = 3 opt-level = 3 [patch.crates-io] -strois = { git = "http://github.com/meilisearch/strois", rev = "eeb945c" } +strois = { git = "https://github.com/meilisearch/strois", rev = "eeb945c" } + +[patch."https://github.com/irevoire/zookeeper-client-sync"] +zookeeper-client-sync = { path = "../zookeeper-client-sync" } diff --git a/meilisearch-auth/src/lib.rs b/meilisearch-auth/src/lib.rs index 08872450e..f6b1d45ca 100644 --- a/meilisearch-auth/src/lib.rs +++ b/meilisearch-auth/src/lib.rs @@ -50,7 +50,7 @@ impl AuthController { EventType::NodeDeleted => { // TODO: ugly unwraps let uuid = path.strip_prefix("/auth/").unwrap(); - let uuid = Uuid::parse_str(&uuid).unwrap(); + let uuid = Uuid::parse_str(uuid).unwrap(); log::info!("The key {} has been deleted", uuid); controller_clone.store.delete_api_key(uuid).unwrap(); } @@ -58,7 +58,7 @@ impl AuthController { if path.strip_prefix("/auth/").map_or(false, |s| !s.is_empty()) { let (key, _stat) = zkk.get_data(&path).unwrap(); let key: Key = serde_json::from_slice(&key).unwrap(); - log::info!("The key {} has been deleted", key.uid); + log::info!("The key {} has been inserted", key.uid); controller_clone.store.put_api_key(key).unwrap(); } } diff --git a/meilisearch/src/lib.rs b/meilisearch/src/lib.rs index 69993bc0b..e80dcc409 100644 --- a/meilisearch/src/lib.rs +++ b/meilisearch/src/lib.rs @@ -138,7 +138,7 @@ enum OnFailure { KeepDb, } -pub async fn setup_meilisearch( +pub fn setup_meilisearch( opt: &Opt, zookeeper: Option>, ) -> anyhow::Result<(Arc, Arc)> { diff --git a/meilisearch/src/main.rs b/meilisearch/src/main.rs index 8db217f5c..3c15ea358 100644 --- a/meilisearch/src/main.rs +++ b/meilisearch/src/main.rs @@ -68,7 +68,9 @@ async fn main() -> anyhow::Result<()> { Some(ref url) => Some(Arc::new(Zookeeper::connect(url).await.unwrap())), None => None, }; - let (index_scheduler, auth_controller) = setup_meilisearch(&opt, zookeeper).await?; + let optc = opt.clone(); + let (index_scheduler, auth_controller) = + tokio::task::spawn_blocking(move || setup_meilisearch(&optc, zookeeper)).await.unwrap()?; #[cfg(all(not(debug_assertions), feature = "analytics"))] let analytics = if !opt.no_analytics {