diff --git a/crates/index-scheduler/src/lib.rs b/crates/index-scheduler/src/lib.rs index cef24c1ea..c719bb35e 100644 --- a/crates/index-scheduler/src/lib.rs +++ b/crates/index-scheduler/src/lib.rs @@ -1738,11 +1738,8 @@ impl IndexScheduler { } } - self.processing_tasks.write().unwrap().stop_processing(); // We must re-add the canceled task so they're part of the same batch. - // processed.processing |= canceled; ids |= canceled; - self.write_batch(&mut wtxn, processing_batch, &ids)?; #[cfg(test)] @@ -1750,6 +1747,10 @@ impl IndexScheduler { wtxn.commit().map_err(Error::HeedTransaction)?; + // We should stop processing AFTER everything is processed and written to disk otherwise, a batch (which only lives in RAM) may appear in the processing task + // and then become « not found » for some time until the commit everything is written and the final commit is made. + self.processing_tasks.write().unwrap().stop_processing(); + // Once the tasks are committed, we should delete all the update files associated ASAP to avoid leaking files in case of a restart tracing::debug!("Deleting the update files"); diff --git a/crates/meilisearch/tests/batches/mod.rs b/crates/meilisearch/tests/batches/mod.rs index 799aa3df7..9c869c140 100644 --- a/crates/meilisearch/tests/batches/mod.rs +++ b/crates/meilisearch/tests/batches/mod.rs @@ -224,7 +224,7 @@ async fn list_batches_status_and_type_filtered() { } #[actix_rt::test] -async fn get_batch_filter_error() { +async fn list_batch_filter_error() { let server = Server::new().await; let (response, code) = server.batches_filter("lol=pied").await;