From c064737137012b7e5d0bd2a1e1ecf4ead07a4eb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Thu, 16 Oct 2025 16:33:20 +0200 Subject: [PATCH] Remove duplicated logic in auto batching of tasks --- .../src/scheduler/autobatcher.rs | 20 ++++--------------- .../src/scheduler/create_batch.rs | 6 ------ 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/crates/index-scheduler/src/scheduler/autobatcher.rs b/crates/index-scheduler/src/scheduler/autobatcher.rs index 94f3e64fc..87818c5aa 100644 --- a/crates/index-scheduler/src/scheduler/autobatcher.rs +++ b/crates/index-scheduler/src/scheduler/autobatcher.rs @@ -25,7 +25,6 @@ enum AutobatchKind { IndexDeletion, IndexUpdate, IndexSwap, - IndexCompaction, } impl AutobatchKind { @@ -69,14 +68,14 @@ impl From for AutobatchKind { KindWithContent::IndexCreation { .. } => AutobatchKind::IndexCreation, KindWithContent::IndexUpdate { .. } => AutobatchKind::IndexUpdate, KindWithContent::IndexSwap { .. } => AutobatchKind::IndexSwap, - KindWithContent::IndexCompaction { .. } => AutobatchKind::IndexCompaction, - KindWithContent::TaskCancelation { .. } + KindWithContent::IndexCompaction { .. } + | KindWithContent::TaskCancelation { .. } | KindWithContent::TaskDeletion { .. } | KindWithContent::DumpCreation { .. } | KindWithContent::Export { .. } | KindWithContent::UpgradeDatabase { .. } | KindWithContent::SnapshotCreation => { - panic!("The autobatcher should never be called with tasks that don't apply to an index.") + panic!("The autobatcher should never be called with tasks with special priority or that don't apply to an index.") } } } @@ -120,9 +119,6 @@ pub enum BatchKind { IndexSwap { id: TaskId, }, - IndexCompaction { - id: TaskId, - }, } impl BatchKind { @@ -188,13 +184,6 @@ impl BatchKind { )), false, ), - K::IndexCompaction => ( - Break(( - BatchKind::IndexCompaction { id: task_id }, - BatchStopReason::TaskCannotBeBatched { kind, id: task_id }, - )), - false, - ), K::DocumentClear => (Continue(BatchKind::DocumentClear { ids: vec![task_id] }), false), K::DocumentImport { allow_index_creation, primary_key: pk } if primary_key.is_none() || pk.is_none() || primary_key == pk.as_deref() => @@ -300,7 +289,7 @@ impl BatchKind { match (self, autobatch_kind) { // We don't batch any of these operations - (this, K::IndexCreation | K::IndexUpdate | K::IndexSwap | K::DocumentEdition | K::IndexCompaction) => { + (this, K::IndexCreation | K::IndexUpdate | K::IndexSwap | K::DocumentEdition) => { Break((this, BatchStopReason::TaskCannotBeBatched { kind, id })) }, // We must not batch tasks that don't have the same index creation rights if the index doesn't already exists. @@ -497,7 +486,6 @@ impl BatchKind { | BatchKind::IndexDeletion { .. } | BatchKind::IndexUpdate { .. } | BatchKind::IndexSwap { .. } - | BatchKind::IndexCompaction { .. } | BatchKind::DocumentEdition { .. }, _, ) => { diff --git a/crates/index-scheduler/src/scheduler/create_batch.rs b/crates/index-scheduler/src/scheduler/create_batch.rs index 86023c07e..d711a78c2 100644 --- a/crates/index-scheduler/src/scheduler/create_batch.rs +++ b/crates/index-scheduler/src/scheduler/create_batch.rs @@ -437,12 +437,6 @@ impl IndexScheduler { current_batch.processing(Some(&mut task)); Ok(Some(Batch::IndexSwap { task })) } - BatchKind::IndexCompaction { id } => { - let mut task = - self.queue.tasks.get_task(rtxn, id)?.ok_or(Error::CorruptedTaskQueue)?; - current_batch.processing(Some(&mut task)); - Ok(Some(Batch::IndexCompaction { index_uid, task })) - } } }