From bd27fe7d02f51da176f9cfdef9dd9588f0cb5b1a Mon Sep 17 00:00:00 2001 From: ManyTheFish Date: Wed, 12 Feb 2025 11:45:02 +0100 Subject: [PATCH] force dumpless upgrade to recompute stats --- crates/milli/src/update/upgrade/mod.rs | 8 +++++-- crates/milli/src/update/upgrade/v1_12.rs | 7 +++--- crates/milli/src/update/upgrade/v1_13.rs | 29 ++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 crates/milli/src/update/upgrade/v1_13.rs diff --git a/crates/milli/src/update/upgrade/mod.rs b/crates/milli/src/update/upgrade/mod.rs index 5b7fda303..16f0eef7a 100644 --- a/crates/milli/src/update/upgrade/mod.rs +++ b/crates/milli/src/update/upgrade/mod.rs @@ -1,7 +1,9 @@ mod v1_12; +mod v1_13; use heed::RwTxn; -use v1_12::{V1_12_3_To_Current, V1_12_To_V1_12_3}; +use v1_12::{V1_12_3_To_V1_13_0, V1_12_To_V1_12_3}; +use v1_13::V1_13_0_To_Current; use crate::progress::{Progress, VariableNameStep}; use crate::{Index, InternalError, Result}; @@ -26,11 +28,13 @@ pub fn upgrade( progress: Progress, ) -> Result { let from = index.get_version(wtxn)?.unwrap_or(db_version); - let upgrade_functions: &[&dyn UpgradeIndex] = &[&V1_12_To_V1_12_3 {}, &V1_12_3_To_Current()]; + let upgrade_functions: &[&dyn UpgradeIndex] = + &[&V1_12_To_V1_12_3 {}, &V1_12_3_To_V1_13_0 {}, &V1_13_0_To_Current()]; let start = match from { (1, 12, 0..=2) => 0, (1, 12, 3..) => 1, + (1, 13, 0) => 2, // 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, 13, _) => return Ok(false), (major, minor, patch) => { diff --git a/crates/milli/src/update/upgrade/v1_12.rs b/crates/milli/src/update/upgrade/v1_12.rs index 9086e920f..c3228213c 100644 --- a/crates/milli/src/update/upgrade/v1_12.rs +++ b/crates/milli/src/update/upgrade/v1_12.rs @@ -32,9 +32,9 @@ impl UpgradeIndex for V1_12_To_V1_12_3 { } #[allow(non_camel_case_types)] -pub(super) struct V1_12_3_To_Current(); +pub(super) struct V1_12_3_To_V1_13_0 {} -impl UpgradeIndex for V1_12_3_To_Current { +impl UpgradeIndex for V1_12_3_To_V1_13_0 { fn upgrade( &self, _wtxn: &mut RwTxn, @@ -42,7 +42,8 @@ impl UpgradeIndex for V1_12_3_To_Current { _original: (u32, u32, u32), _progress: Progress, ) -> Result { - Ok(false) + // recompute the indexes stats + Ok(true) } fn target_version(&self) -> (u32, u32, u32) { diff --git a/crates/milli/src/update/upgrade/v1_13.rs b/crates/milli/src/update/upgrade/v1_13.rs new file mode 100644 index 000000000..52246a7f3 --- /dev/null +++ b/crates/milli/src/update/upgrade/v1_13.rs @@ -0,0 +1,29 @@ +use heed::RwTxn; + +use super::UpgradeIndex; +use crate::constants::{VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH}; +use crate::progress::Progress; +use crate::{Index, Result}; + +#[allow(non_camel_case_types)] +pub(super) struct V1_13_0_To_Current(); + +impl UpgradeIndex for V1_13_0_To_Current { + 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.parse().unwrap(), + VERSION_MINOR.parse().unwrap(), + VERSION_PATCH.parse().unwrap(), + ) + } +}