diff --git a/crates/index-scheduler/src/insta_snapshot.rs b/crates/index-scheduler/src/insta_snapshot.rs index 4a649f1cb..bb8827fdc 100644 --- a/crates/index-scheduler/src/insta_snapshot.rs +++ b/crates/index-scheduler/src/insta_snapshot.rs @@ -345,10 +345,10 @@ pub fn snapshot_batch(batch: &Batch) -> String { if let Some(finished_at) = finished_at { assert!(finished_at > started_at); } - if let Some(BatchEnqueuedAt { earliest, oldest }) = enqueued_at { - assert!(started_at > earliest); - assert!(earliest >= oldest); - } + let BatchEnqueuedAt { earliest, oldest } = enqueued_at.unwrap(); + assert!(*started_at > earliest); + assert!(earliest >= oldest); + snap.push('{'); snap.push_str(&format!("uid: {uid}, ")); snap.push_str(&format!("details: {}, ", serde_json::to_string(details).unwrap())); diff --git a/crates/index-scheduler/src/utils.rs b/crates/index-scheduler/src/utils.rs index 2a0c47626..42bf253ad 100644 --- a/crates/index-scheduler/src/utils.rs +++ b/crates/index-scheduler/src/utils.rs @@ -359,14 +359,27 @@ impl crate::IndexScheduler { kind, } = task; assert_eq!(uid, task.uid); - if let Some(ref batch) = batch_uid { + if task.status != Status::Enqueued { + let batch_uid = batch_uid.expect("All non enqueued tasks must be part of a batch"); assert!(self .queue .batch_to_tasks_mapping - .get(&rtxn, batch) + .get(&rtxn, &batch_uid) .unwrap() .unwrap() .contains(uid)); + let batch = self.queue.batches.get_batch(&rtxn, batch_uid).unwrap().unwrap(); + assert_eq!(batch.uid, batch_uid); + if task.status == Status::Processing { + assert!(batch.progress.is_some()); + } else { + assert!(batch.progress.is_none()); + } + assert_eq!(batch.started_at, task.started_at.unwrap()); + assert_eq!(batch.finished_at, task.finished_at); + let enqueued_at = batch.enqueued_at.unwrap(); + assert!(task.enqueued_at >= enqueued_at.oldest); + assert!(task.enqueued_at <= enqueued_at.earliest); } if let Some(task_index_uid) = &task_index_uid { assert!(self