From 66aa682e23cfb9538527038e3828d68932b63f32 Mon Sep 17 00:00:00 2001 From: Tamo Date: Thu, 7 Sep 2023 11:37:02 +0200 Subject: [PATCH] Register the swap indexe task in a spawn blocking to be sure to never block the main thread --- meilisearch/src/routes/swap_indexes.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/meilisearch/src/routes/swap_indexes.rs b/meilisearch/src/routes/swap_indexes.rs index c4e204c09..79e619705 100644 --- a/meilisearch/src/routes/swap_indexes.rs +++ b/meilisearch/src/routes/swap_indexes.rs @@ -60,8 +60,7 @@ pub async fn swap_indexes( } let task = KindWithContent::IndexSwap { swaps }; - - let task = index_scheduler.register(task)?; - let task: SummarizedTaskView = task.into(); + let task: SummarizedTaskView = + tokio::task::spawn_blocking(move || index_scheduler.register(task)).await??.into(); Ok(HttpResponse::Accepted().json(task)) }