diff --git a/crates/index-scheduler/src/error.rs b/crates/index-scheduler/src/error.rs index a41672995..d3feecd73 100644 --- a/crates/index-scheduler/src/error.rs +++ b/crates/index-scheduler/src/error.rs @@ -147,7 +147,9 @@ pub enum Error { #[error("Corrupted task queue.")] CorruptedTaskQueue, #[error(transparent)] - TaskDatabaseUpgrade(Box), + DatabaseUpgrade(Box), + #[error(transparent)] + UnrecoverableError(Box), #[error(transparent)] HeedTransaction(heed::Error), @@ -202,7 +204,8 @@ impl Error { | Error::Anyhow(_) => true, Error::CreateBatch(_) | Error::CorruptedTaskQueue - | Error::TaskDatabaseUpgrade(_) + | Error::DatabaseUpgrade(_) + | Error::UnrecoverableError(_) | Error::HeedTransaction(_) => false, #[cfg(test)] Error::PlannedFailure => false, @@ -266,7 +269,8 @@ impl ErrorCode for Error { Error::Anyhow(_) => Code::Internal, Error::CorruptedTaskQueue => Code::Internal, Error::CorruptedDump => Code::Internal, - Error::TaskDatabaseUpgrade(_) => Code::Internal, + Error::DatabaseUpgrade(_) => Code::Internal, + Error::UnrecoverableError(_) => Code::Internal, Error::CreateBatch(_) => Code::Internal, // This one should never be seen by the end user diff --git a/crates/index-scheduler/src/scheduler/mod.rs b/crates/index-scheduler/src/scheduler/mod.rs index 7a55c9f54..eddf8fba7 100644 --- a/crates/index-scheduler/src/scheduler/mod.rs +++ b/crates/index-scheduler/src/scheduler/mod.rs @@ -223,7 +223,7 @@ impl IndexScheduler { self.queue .tasks .update_task(&mut wtxn, &task) - .map_err(|e| Error::TaskDatabaseUpgrade(Box::new(e)))?; + .map_err(|e| Error::UnrecoverableError(Box::new(e)))?; } if let Some(canceled_by) = canceled_by { self.queue.tasks.canceled_by.put(&mut wtxn, &canceled_by, &canceled)?; @@ -274,7 +274,7 @@ impl IndexScheduler { let (task_progress, task_progress_obj) = AtomicTaskStep::new(ids.len() as u32); progress.update_progress(task_progress_obj); - if matches!(err, Error::TaskDatabaseUpgrade(_)) { + if matches!(err, Error::DatabaseUpgrade(_)) { tracing::error!( "Upgrade task failed, tasks won't be processed until the following issue is fixed: {err}" ); @@ -287,7 +287,7 @@ impl IndexScheduler { .queue .tasks .get_task(&wtxn, id) - .map_err(|e| Error::TaskDatabaseUpgrade(Box::new(e)))? + .map_err(|e| Error::UnrecoverableError(Box::new(e)))? .ok_or(Error::CorruptedTaskQueue)?; task.status = Status::Failed; task.error = Some(error.clone()); @@ -304,7 +304,7 @@ impl IndexScheduler { self.queue .tasks .update_task(&mut wtxn, &task) - .map_err(|e| Error::TaskDatabaseUpgrade(Box::new(e)))?; + .map_err(|e| Error::UnrecoverableError(Box::new(e)))?; } } } @@ -334,7 +334,7 @@ impl IndexScheduler { .queue .tasks .get_task(&rtxn, id) - .map_err(|e| Error::TaskDatabaseUpgrade(Box::new(e)))? + .map_err(|e| Error::UnrecoverableError(Box::new(e)))? .ok_or(Error::CorruptedTaskQueue)?; if let Err(e) = self.queue.delete_persisted_task_data(&task) { tracing::error!( diff --git a/crates/index-scheduler/src/scheduler/process_batch.rs b/crates/index-scheduler/src/scheduler/process_batch.rs index 2f4a8e7da..d54c9a171 100644 --- a/crates/index-scheduler/src/scheduler/process_batch.rs +++ b/crates/index-scheduler/src/scheduler/process_batch.rs @@ -319,11 +319,9 @@ impl IndexScheduler { let ret = catch_unwind(AssertUnwindSafe(|| self.process_upgrade(progress))); match ret { Ok(Ok(())) => (), - Ok(Err(e)) => return Err(Error::TaskDatabaseUpgrade(Box::new(e))), + Ok(Err(e)) => return Err(Error::DatabaseUpgrade(Box::new(e))), Err(_e) => { - return Err(Error::TaskDatabaseUpgrade(Box::new( - Error::ProcessBatchPanicked, - ))); + return Err(Error::DatabaseUpgrade(Box::new(Error::ProcessBatchPanicked))); } }