From 75c0718691f1efd4eb004dde1aa9aaec08a7ba2e Mon Sep 17 00:00:00 2001 From: marin postma Date: Wed, 2 Jun 2021 15:20:32 +0200 Subject: [PATCH] fix update loop infinite loop --- .../src/index_controller/index_actor/actor.rs | 4 +--- .../src/index_controller/update_actor/store/mod.rs | 8 ++++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/meilisearch-http/src/index_controller/index_actor/actor.rs b/meilisearch-http/src/index_controller/index_actor/actor.rs index 31e2a58d4..4d8324e11 100644 --- a/meilisearch-http/src/index_controller/index_actor/actor.rs +++ b/meilisearch-http/src/index_controller/index_actor/actor.rs @@ -168,9 +168,7 @@ impl IndexActor { None => self.store.create(uuid, None).await?, }; - let result = - spawn_blocking(move || update_handler.handle_update(meta, data, index)).await?; - Ok(result) + Ok(spawn_blocking(move || update_handler.handle_update(meta, data, index)).await?) } async fn handle_settings(&self, uuid: Uuid) -> IndexResult> { diff --git a/meilisearch-http/src/index_controller/update_actor/store/mod.rs b/meilisearch-http/src/index_controller/update_actor/store/mod.rs index 28204f4c0..39de02ef1 100644 --- a/meilisearch-http/src/index_controller/update_actor/store/mod.rs +++ b/meilisearch-http/src/index_controller/update_actor/store/mod.rs @@ -303,9 +303,13 @@ impl UpdateStore { } None => None, }; + // Process the pending update using the provided user function. - let result = Handle::current() - .block_on(index_handle.update(index_uuid, processing, file))?; + let handle = Handle::current(); + let result = match handle.block_on(index_handle.update(index_uuid, processing.clone(), file)) { + Ok(result) => result, + Err(e) => Err(processing.fail(e.to_string())), + }; // Once the pending update have been successfully processed // we must remove the content from the pending and processing stores and