make sure the batches we snapshots actually all contains an enqueued_at

This commit is contained in:
Tamo 2025-01-28 11:51:07 +01:00
parent 485e3127c7
commit e0f0da57e2
No known key found for this signature in database
GPG Key ID: 20CD8020AFA88D69
2 changed files with 19 additions and 6 deletions

View File

@ -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()));

View File

@ -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