From f349630e7853f85a179c2aa752833100ffa0ced2 Mon Sep 17 00:00:00 2001 From: ManyTheFish Date: Mon, 12 May 2025 13:53:23 +0200 Subject: [PATCH 1/2] Add v1.15 in index-scheduler upgrade --- crates/index-scheduler/src/upgrade/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/index-scheduler/src/upgrade/mod.rs b/crates/index-scheduler/src/upgrade/mod.rs index 74c8ee696..ded56bd2d 100644 --- a/crates/index-scheduler/src/upgrade/mod.rs +++ b/crates/index-scheduler/src/upgrade/mod.rs @@ -34,6 +34,7 @@ pub fn upgrade_index_scheduler( (1, 12, _) => 0, (1, 13, _) => 0, (1, 14, _) => 0, + (1, 15, _) => 0, (major, minor, patch) => { if major > current_major || (major == current_major && minor > current_minor) From d99419acfb3343c23a82a57c0ec3f2d4a54965ef Mon Sep 17 00:00:00 2001 From: ManyTheFish Date: Mon, 12 May 2025 14:19:15 +0200 Subject: [PATCH 2/2] Add a NoOp operation in index update --- crates/index-scheduler/src/upgrade/mod.rs | 6 +++++- crates/milli/src/update/upgrade/mod.rs | 25 ++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/crates/index-scheduler/src/upgrade/mod.rs b/crates/index-scheduler/src/upgrade/mod.rs index ded56bd2d..2053caa92 100644 --- a/crates/index-scheduler/src/upgrade/mod.rs +++ b/crates/index-scheduler/src/upgrade/mod.rs @@ -28,7 +28,11 @@ pub fn upgrade_index_scheduler( let current_minor = to.1; let current_patch = to.2; - let upgrade_functions: &[&dyn UpgradeIndexScheduler] = &[&ToCurrentNoOp {}]; + let upgrade_functions: &[&dyn UpgradeIndexScheduler] = &[ + // This is the last upgrade function, it will be called when the index is up to date. + // any other upgrade function should be added before this one. + &ToCurrentNoOp {}, + ]; let start = match from { (1, 12, _) => 0, diff --git a/crates/milli/src/update/upgrade/mod.rs b/crates/milli/src/update/upgrade/mod.rs index f9d971017..9f64ca0e3 100644 --- a/crates/milli/src/update/upgrade/mod.rs +++ b/crates/milli/src/update/upgrade/mod.rs @@ -8,6 +8,7 @@ use v1_13::{V1_13_0_To_V1_13_1, V1_13_1_To_Latest_V1_13}; use v1_14::Latest_V1_13_To_Latest_V1_14; use v1_15::Latest_V1_14_To_Latest_V1_15; +use crate::constants::{VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH}; use crate::progress::{Progress, VariableNameStep}; use crate::{Index, InternalError, Result}; @@ -42,6 +43,9 @@ where &V1_13_1_To_Latest_V1_13 {}, &Latest_V1_13_To_Latest_V1_14 {}, &Latest_V1_14_To_Latest_V1_15 {}, + // This is the last upgrade function, it will be called when the index is up to date. + // any other upgrade function should be added before this one. + &ToCurrentNoOp {}, ]; let start = match from { @@ -51,7 +55,7 @@ where (1, 13, _) => 4, (1, 14, _) => 5, // We must handle the current version in the match because in case of a failure some index may have been upgraded but not other. - (1, 15, _) => 5, + (1, 15, _) => 6, (major, minor, patch) => { return Err(InternalError::CannotUpgradeToVersion(major, minor, patch).into()) } @@ -87,3 +91,22 @@ where Ok(regenerate_stats) } + +#[allow(non_camel_case_types)] +struct ToCurrentNoOp {} + +impl UpgradeIndex for ToCurrentNoOp { + fn upgrade( + &self, + _wtxn: &mut RwTxn, + _index: &Index, + _original: (u32, u32, u32), + _progress: Progress, + ) -> Result { + Ok(false) + } + + fn target_version(&self) -> (u32, u32, u32) { + (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH) + } +}