mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 14:54:27 +01:00
Let the tick function set the Failed status itself
This commit is contained in:
parent
566c15fb74
commit
b24b13b036
@ -496,20 +496,16 @@ impl IndexScheduler {
|
|||||||
) -> Result<Vec<Task>> {
|
) -> Result<Vec<Task>> {
|
||||||
match operation {
|
match operation {
|
||||||
IndexOperation::DocumentClear { mut tasks, .. } => {
|
IndexOperation::DocumentClear { mut tasks, .. } => {
|
||||||
let result = milli::update::ClearDocuments::new(index_wtxn, index).execute();
|
let count = milli::update::ClearDocuments::new(index_wtxn, index).execute()?;
|
||||||
|
|
||||||
for task in &mut tasks {
|
for task in &mut tasks {
|
||||||
match result {
|
|
||||||
Ok(deleted_documents) => {
|
|
||||||
task.status = Status::Succeeded;
|
task.status = Status::Succeeded;
|
||||||
task.details = Some(Details::ClearAll {
|
task.details = match &task.kind {
|
||||||
deleted_documents: Some(deleted_documents),
|
KindWithContent::DocumentClear { .. } => Some(Details::ClearAll {
|
||||||
});
|
deleted_documents: Some(count),
|
||||||
}
|
}),
|
||||||
Err(ref error) => {
|
otherwise => otherwise.default_details(),
|
||||||
task.status = Status::Failed;
|
};
|
||||||
task.error = Some(MilliError(error).into())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(tasks)
|
Ok(tasks)
|
||||||
@ -608,25 +604,17 @@ impl IndexScheduler {
|
|||||||
builder.delete_external_id(id);
|
builder.delete_external_id(id);
|
||||||
});
|
});
|
||||||
|
|
||||||
let result = builder.execute();
|
let DocumentDeletionResult {
|
||||||
|
deleted_documents, ..
|
||||||
|
} = builder.execute()?;
|
||||||
|
|
||||||
for (task, documents) in tasks.iter_mut().zip(documents) {
|
for (task, documents) in tasks.iter_mut().zip(documents) {
|
||||||
match result {
|
|
||||||
Ok(DocumentDeletionResult {
|
|
||||||
deleted_documents,
|
|
||||||
remaining_documents: _,
|
|
||||||
}) => {
|
|
||||||
task.status = Status::Succeeded;
|
task.status = Status::Succeeded;
|
||||||
task.details = Some(Details::DocumentDeletion {
|
task.details = Some(Details::DocumentDeletion {
|
||||||
received_document_ids: documents.len(),
|
received_document_ids: documents.len(),
|
||||||
deleted_documents: Some(deleted_documents),
|
deleted_documents: Some(deleted_documents),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Err(ref error) => {
|
|
||||||
task.status = Status::Failed;
|
|
||||||
task.error = Some(MilliError(error).into());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(tasks)
|
Ok(tasks)
|
||||||
}
|
}
|
||||||
@ -644,17 +632,11 @@ impl IndexScheduler {
|
|||||||
let mut builder =
|
let mut builder =
|
||||||
milli::update::Settings::new(index_wtxn, index, indexer_config);
|
milli::update::Settings::new(index_wtxn, index, indexer_config);
|
||||||
apply_settings_to_builder(&checked_settings, &mut builder);
|
apply_settings_to_builder(&checked_settings, &mut builder);
|
||||||
let result = builder.execute(|indexing_step| {
|
builder.execute(|indexing_step| {
|
||||||
debug!("update: {:?}", indexing_step);
|
debug!("update: {:?}", indexing_step);
|
||||||
});
|
})?;
|
||||||
|
|
||||||
match result {
|
task.status = Status::Succeeded;
|
||||||
Ok(_) => task.status = Status::Succeeded,
|
|
||||||
Err(ref error) => {
|
|
||||||
task.status = Status::Failed;
|
|
||||||
task.error = Some(MilliError(error).into());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(tasks)
|
Ok(tasks)
|
||||||
|
@ -17,6 +17,7 @@ use std::path::PathBuf;
|
|||||||
use std::sync::{Arc, RwLock};
|
use std::sync::{Arc, RwLock};
|
||||||
|
|
||||||
use file_store::{File, FileStore};
|
use file_store::{File, FileStore};
|
||||||
|
use meilisearch_types::error::ResponseError;
|
||||||
use roaring::RoaringBitmap;
|
use roaring::RoaringBitmap;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use synchronoise::SignalEvent;
|
use synchronoise::SignalEvent;
|
||||||
@ -407,14 +408,14 @@ impl IndexScheduler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// In case of a failure we must get back and patch all the tasks with the error.
|
// In case of a failure we must get back and patch all the tasks with the error.
|
||||||
Err(_err) => {
|
Err(err) => {
|
||||||
|
let error: ResponseError = err.into();
|
||||||
for id in ids {
|
for id in ids {
|
||||||
let mut task = self.get_task(&wtxn, id)?.ok_or(Error::CorruptedTaskQueue)?;
|
let mut task = self.get_task(&wtxn, id)?.ok_or(Error::CorruptedTaskQueue)?;
|
||||||
task.started_at = Some(started_at);
|
task.started_at = Some(started_at);
|
||||||
task.finished_at = Some(finished_at);
|
task.finished_at = Some(finished_at);
|
||||||
task.status = Status::Failed;
|
task.status = Status::Failed;
|
||||||
// TODO: TAMO: set the error correctly
|
task.error = Some(error.clone());
|
||||||
// task.error = Some(err);
|
|
||||||
|
|
||||||
self.update_task(&mut wtxn, &task)?;
|
self.update_task(&mut wtxn, &task)?;
|
||||||
task.remove_data()?;
|
task.remove_data()?;
|
||||||
|
Loading…
Reference in New Issue
Block a user