mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 12:05:05 +08:00
Add a dedicated error variant for planned failures in index scheduler tests
Fixes #3086
This commit is contained in:
parent
134e7fc433
commit
d09b771bce
@ -134,6 +134,48 @@ pub enum Error {
|
|||||||
TaskDatabaseUpdate(Box<Self>),
|
TaskDatabaseUpdate(Box<Self>),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
HeedTransaction(heed::Error),
|
HeedTransaction(heed::Error),
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
#[error("Planned failure for tests.")]
|
||||||
|
PlannedFailure,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Error {
|
||||||
|
pub fn is_recoverable(&self) -> bool {
|
||||||
|
match self {
|
||||||
|
Error::IndexNotFound(_)
|
||||||
|
| Error::IndexAlreadyExists(_)
|
||||||
|
| Error::SwapDuplicateIndexFound(_)
|
||||||
|
| Error::SwapDuplicateIndexesFound(_)
|
||||||
|
| Error::SwapIndexNotFound(_)
|
||||||
|
| Error::NoSpaceLeftInTaskQueue
|
||||||
|
| Error::SwapIndexesNotFound(_)
|
||||||
|
| Error::CorruptedDump
|
||||||
|
| Error::InvalidTaskDate { .. }
|
||||||
|
| Error::InvalidTaskUids { .. }
|
||||||
|
| Error::InvalidTaskStatuses { .. }
|
||||||
|
| Error::InvalidTaskTypes { .. }
|
||||||
|
| Error::InvalidTaskCanceledBy { .. }
|
||||||
|
| Error::InvalidIndexUid { .. }
|
||||||
|
| Error::TaskNotFound(_)
|
||||||
|
| Error::TaskDeletionWithEmptyQuery
|
||||||
|
| Error::TaskCancelationWithEmptyQuery
|
||||||
|
| Error::Dump(_)
|
||||||
|
| Error::Heed(_)
|
||||||
|
| Error::Milli(_)
|
||||||
|
| Error::ProcessBatchPanicked
|
||||||
|
| Error::FileStore(_)
|
||||||
|
| Error::IoError(_)
|
||||||
|
| Error::Persist(_)
|
||||||
|
| Error::Anyhow(_) => true,
|
||||||
|
Error::CreateBatch(_)
|
||||||
|
| Error::CorruptedTaskQueue
|
||||||
|
| Error::TaskDatabaseUpdate(_)
|
||||||
|
| Error::HeedTransaction(_) => false,
|
||||||
|
#[cfg(test)]
|
||||||
|
Error::PlannedFailure => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ErrorCode for Error {
|
impl ErrorCode for Error {
|
||||||
@ -171,6 +213,9 @@ impl ErrorCode for Error {
|
|||||||
Error::CorruptedDump => Code::Internal,
|
Error::CorruptedDump => Code::Internal,
|
||||||
Error::TaskDatabaseUpdate(_) => Code::Internal,
|
Error::TaskDatabaseUpdate(_) => Code::Internal,
|
||||||
Error::CreateBatch(_) => Code::Internal,
|
Error::CreateBatch(_) => Code::Internal,
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
Error::PlannedFailure => Code::Internal,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -530,13 +530,7 @@ impl IndexScheduler {
|
|||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("{}", e);
|
log::error!("{}", e);
|
||||||
// Wait one second when an irrecoverable error occurs.
|
// Wait one second when an irrecoverable error occurs.
|
||||||
if matches!(
|
if !e.is_recoverable() {
|
||||||
e,
|
|
||||||
Error::CorruptedTaskQueue
|
|
||||||
| Error::TaskDatabaseUpdate(_)
|
|
||||||
| Error::HeedTransaction(_)
|
|
||||||
| Error::CreateBatch(_)
|
|
||||||
) {
|
|
||||||
std::thread::sleep(Duration::from_secs(1));
|
std::thread::sleep(Duration::from_secs(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1426,7 +1420,7 @@ mod tests {
|
|||||||
(index_scheduler, index_scheduler_handle)
|
(index_scheduler, index_scheduler_handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return a [`CorruptedTaskQueue`](Error::CorruptedTaskQueue) error if a failure is planned
|
/// Return a [`PlannedFailure`](Error::PlannedFailure) error if a failure is planned
|
||||||
/// for the given location and current run loop iteration.
|
/// for the given location and current run loop iteration.
|
||||||
pub fn maybe_fail(&self, location: FailureLocation) -> Result<()> {
|
pub fn maybe_fail(&self, location: FailureLocation) -> Result<()> {
|
||||||
if self.planned_failures.contains(&(*self.run_loop_iteration.read().unwrap(), location))
|
if self.planned_failures.contains(&(*self.run_loop_iteration.read().unwrap(), location))
|
||||||
@ -1435,7 +1429,7 @@ mod tests {
|
|||||||
FailureLocation::PanicInsideProcessBatch => {
|
FailureLocation::PanicInsideProcessBatch => {
|
||||||
panic!("simulated panic")
|
panic!("simulated panic")
|
||||||
}
|
}
|
||||||
_ => Err(Error::CorruptedTaskQueue),
|
_ => Err(Error::PlannedFailure),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -6,7 +6,7 @@ source: index-scheduler/src/lib.rs
|
|||||||
[]
|
[]
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
### All Tasks:
|
### All Tasks:
|
||||||
0 {uid: 0, status: failed, error: ResponseError { code: 200, message: "Corrupted task queue.", error_code: "internal", error_type: "internal", error_link: "https://docs.meilisearch.com/errors#internal" }, details: { received_documents: 1, indexed_documents: Some(0) }, kind: DocumentAdditionOrUpdate { index_uid: "doggos", primary_key: Some("id"), method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }}
|
0 {uid: 0, status: failed, error: ResponseError { code: 200, message: "Planned failure for tests.", error_code: "internal", error_type: "internal", error_link: "https://docs.meilisearch.com/errors#internal" }, details: { received_documents: 1, indexed_documents: Some(0) }, kind: DocumentAdditionOrUpdate { index_uid: "doggos", primary_key: Some("id"), method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }}
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
### Status:
|
### Status:
|
||||||
enqueued []
|
enqueued []
|
||||||
|
@ -6,7 +6,7 @@ source: index-scheduler/src/lib.rs
|
|||||||
[]
|
[]
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
### All Tasks:
|
### All Tasks:
|
||||||
0 {uid: 0, status: failed, error: ResponseError { code: 200, message: "Corrupted task queue.", error_code: "internal", error_type: "internal", error_link: "https://docs.meilisearch.com/errors#internal" }, details: { primary_key: Some("mouse") }, kind: IndexCreation { index_uid: "catto", primary_key: Some("mouse") }}
|
0 {uid: 0, status: failed, error: ResponseError { code: 200, message: "Planned failure for tests.", error_code: "internal", error_type: "internal", error_link: "https://docs.meilisearch.com/errors#internal" }, details: { primary_key: Some("mouse") }, kind: IndexCreation { index_uid: "catto", primary_key: Some("mouse") }}
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
### Status:
|
### Status:
|
||||||
enqueued []
|
enqueued []
|
||||||
|
@ -8,7 +8,7 @@ source: index-scheduler/src/lib.rs
|
|||||||
### All Tasks:
|
### All Tasks:
|
||||||
0 {uid: 0, status: succeeded, details: { primary_key: Some("mouse") }, kind: IndexCreation { index_uid: "catto", primary_key: Some("mouse") }}
|
0 {uid: 0, status: succeeded, details: { primary_key: Some("mouse") }, kind: IndexCreation { index_uid: "catto", primary_key: Some("mouse") }}
|
||||||
1 {uid: 1, status: succeeded, details: { primary_key: Some("sheep") }, kind: IndexCreation { index_uid: "doggo", primary_key: Some("sheep") }}
|
1 {uid: 1, status: succeeded, details: { primary_key: Some("sheep") }, kind: IndexCreation { index_uid: "doggo", primary_key: Some("sheep") }}
|
||||||
2 {uid: 2, status: failed, error: ResponseError { code: 200, message: "Corrupted task queue.", error_code: "internal", error_type: "internal", error_link: "https://docs.meilisearch.com/errors#internal" }, details: { primary_key: Some("fish") }, kind: IndexCreation { index_uid: "whalo", primary_key: Some("fish") }}
|
2 {uid: 2, status: failed, error: ResponseError { code: 200, message: "Planned failure for tests.", error_code: "internal", error_type: "internal", error_link: "https://docs.meilisearch.com/errors#internal" }, details: { primary_key: Some("fish") }, kind: IndexCreation { index_uid: "whalo", primary_key: Some("fish") }}
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
### Status:
|
### Status:
|
||||||
enqueued []
|
enqueued []
|
||||||
|
Loading…
Reference in New Issue
Block a user