From 96cc5319c89b4743cfb406838d57b126b038b918 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Mon, 22 Apr 2024 15:46:16 +0200 Subject: [PATCH] Introduce a new internal error type to categorize panics --- milli/src/error.rs | 2 ++ milli/src/update/index_documents/mod.rs | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/milli/src/error.rs b/milli/src/error.rs index 1d61bef63..a5ed47c7d 100644 --- a/milli/src/error.rs +++ b/milli/src/error.rs @@ -49,6 +49,8 @@ pub enum InternalError { InvalidDatabaseTyping, #[error(transparent)] RayonThreadPool(#[from] ThreadPoolBuildError), + #[error("A panic occured. Read the logs to find more information about it.")] + PanicInThreadPool, #[error(transparent)] SerdeJson(#[from] serde_json::Error), #[error(transparent)] diff --git a/milli/src/update/index_documents/mod.rs b/milli/src/update/index_documents/mod.rs index 3b27f96f4..c61c83757 100644 --- a/milli/src/update/index_documents/mod.rs +++ b/milli/src/update/index_documents/mod.rs @@ -540,6 +540,11 @@ where Ok(()) })?; + // While reseting the pool panic catcher we return an error if we catched one. + if pool_catched_panic.swap(false, Ordering::SeqCst) { + return Err(InternalError::PanicInThreadPool.into()); + } + // We write the field distribution into the main database self.index.put_field_distribution(self.wtxn, &field_distribution)?; @@ -568,6 +573,11 @@ where } Result::Ok(()) })?; + + // While reseting the pool panic catcher we return an error if we catched one. + if pool_catched_panic.swap(false, Ordering::SeqCst) { + return Err(InternalError::PanicInThreadPool.into()); + } } self.execute_prefix_databases(