no deadlock on start

This commit is contained in:
Tamo 2023-11-02 16:45:33 +01:00
parent 0c18962b13
commit d0a3582a56
5 changed files with 11 additions and 7 deletions

3
Cargo.lock generated
View File

@ -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",

View File

@ -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" }

View File

@ -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();
}
}

View File

@ -138,7 +138,7 @@ enum OnFailure {
KeepDb,
}
pub async fn setup_meilisearch(
pub fn setup_meilisearch(
opt: &Opt,
zookeeper: Option<Arc<Zookeeper>>,
) -> anyhow::Result<(Arc<IndexScheduler>, Arc<AuthController>)> {

View File

@ -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 {