diff --git a/crates/index-scheduler/src/batch.rs b/crates/index-scheduler/src/batch.rs index c06cb6b42..13ba70cc6 100644 --- a/crates/index-scheduler/src/batch.rs +++ b/crates/index-scheduler/src/batch.rs @@ -1343,6 +1343,7 @@ impl IndexScheduler { &rtxn, primary_key.as_deref(), &mut new_fields_ids_map, + &|| must_stop_processing.get(), )?; let mut addition = 0; diff --git a/crates/milli/src/update/new/indexer/document_operation.rs b/crates/milli/src/update/new/indexer/document_operation.rs index 7e3990a16..e5148258d 100644 --- a/crates/milli/src/update/new/indexer/document_operation.rs +++ b/crates/milli/src/update/new/indexer/document_operation.rs @@ -41,14 +41,18 @@ impl<'pl> DocumentOperation<'pl> { self.operations.push(Payload::Deletion(to_delete)) } - pub fn into_changes( + pub fn into_changes( self, indexer: &'pl Bump, index: &Index, rtxn: &'pl RoTxn<'pl>, primary_key_from_op: Option<&'pl str>, new_fields_ids_map: &mut FieldsIdsMap, - ) -> Result<(DocumentOperationChanges<'pl>, Vec, Option>)> { + must_stop_processing: &MSP, + ) -> Result<(DocumentOperationChanges<'pl>, Vec, Option>)> + where + MSP: Fn() -> bool, + { let Self { operations, method } = self; let documents_ids = index.documents_ids(rtxn)?; @@ -58,6 +62,9 @@ impl<'pl> DocumentOperation<'pl> { let mut primary_key = None; for operation in operations { + if (must_stop_processing)() { + return Err(InternalError::AbortedIndexation.into()); + } let mut bytes = 0; let result = match operation { Payload::Addition(payload) => extract_addition_payload_changes(