From a083c9e452359a6b0aff9dbcb2b31ba6cce78d68 Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Wed, 5 Oct 2022 16:54:06 +0200 Subject: [PATCH] Only mark the first clear document with the amount of cleared documents --- index-scheduler/src/batch.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/index-scheduler/src/batch.rs b/index-scheduler/src/batch.rs index eef2c3206..97dd9b7a1 100644 --- a/index-scheduler/src/batch.rs +++ b/index-scheduler/src/batch.rs @@ -498,12 +498,19 @@ impl IndexScheduler { IndexOperation::DocumentClear { mut tasks, .. } => { let count = milli::update::ClearDocuments::new(index_wtxn, index).execute()?; + let mut first_clear_found = false; for task in &mut tasks { task.status = Status::Succeeded; + // The first document clear will effectively delete every documents + // in the database but the next ones will clear 0 documents. task.details = match &task.kind { - KindWithContent::DocumentClear { .. } => Some(Details::ClearAll { - deleted_documents: Some(count), - }), + KindWithContent::DocumentClear { .. } => { + let count = if first_clear_found { 0 } else { count }; + first_clear_found = true; + Some(Details::ClearAll { + deleted_documents: Some(count), + }) + } otherwise => otherwise.default_details(), }; }