tick: always refuse to batch tasks when the version in the index-scheduler is wrong

This commit is contained in:
Louis Dureuil 2025-04-22 09:37:03 +02:00
parent 63b5e21ae1
commit 1bdc08a73a
No known key found for this signature in database

View File

@ -473,17 +473,21 @@ impl IndexScheduler {
return Ok(Some((Batch::UpgradeDatabase { tasks }, current_batch))); return Ok(Some((Batch::UpgradeDatabase { tasks }, current_batch)));
} }
// 1. we get the last task to cancel. // check the version of the scheduler here.
let to_cancel = self.queue.tasks.get_kind(rtxn, Kind::TaskCancelation)? & enqueued; // if the version is not the current, refuse to batch any additional task.
if let Some(task_id) = to_cancel.max() { let version = self.version.get_version(rtxn)?;
let mut task = let package_version = (
self.queue.tasks.get_task(rtxn, task_id)?.ok_or(Error::CorruptedTaskQueue)?; meilisearch_types::versioning::VERSION_MAJOR,
current_batch.processing(Some(&mut task)); meilisearch_types::versioning::VERSION_MINOR,
current_batch.reason(BatchStopReason::TaskCannotBeBatched { meilisearch_types::versioning::VERSION_PATCH,
kind: Kind::TaskCancelation, );
id: task_id, if version != Some(package_version) {
}); return Err(Error::UnrecoverableError(Box::new(
return Ok(Some((Batch::TaskCancelation { task }, current_batch))); Error::IndexSchedulerVersionMismatch {
index_scheduler_version: version.unwrap_or((1, 12, 0)),
package_version,
},
)));
} }
// 2. we get the next task to delete // 2. we get the next task to delete