mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-10-31 16:06:31 +00:00 
			
		
		
		
	introduce a trait to upgrade the indexes
This commit is contained in:
		| @@ -316,7 +316,10 @@ impl IndexScheduler { | ||||
|                 Ok(vec![task]) | ||||
|             } | ||||
|             Batch::UpgradeDatabase { mut tasks } => { | ||||
|                 let ret = catch_unwind(AssertUnwindSafe(|| self.process_upgrade(progress))); | ||||
|                 let KindWithContent::UpgradeDatabase { from } = tasks.last().unwrap().kind else { | ||||
|                     unreachable!(); | ||||
|                 }; | ||||
|                 let ret = catch_unwind(AssertUnwindSafe(|| self.process_upgrade(from, progress))); | ||||
|                 match ret { | ||||
|                     Ok(Ok(())) => (), | ||||
|                     Ok(Err(e)) => return Err(Error::DatabaseUpgrade(Box::new(e))), | ||||
|   | ||||
| @@ -4,7 +4,11 @@ use meilisearch_types::milli::progress::{Progress, VariableNameStep}; | ||||
| use crate::{Error, IndexScheduler, Result}; | ||||
|  | ||||
| impl IndexScheduler { | ||||
|     pub(super) fn process_upgrade(&self, progress: Progress) -> Result<()> { | ||||
|     pub(super) fn process_upgrade( | ||||
|         &self, | ||||
|         db_version: (u32, u32, u32), | ||||
|         progress: Progress, | ||||
|     ) -> Result<()> { | ||||
|         #[cfg(test)] | ||||
|         self.maybe_fail(crate::test_utils::FailureLocation::ProcessUpgrade)?; | ||||
|  | ||||
| @@ -19,9 +23,13 @@ impl IndexScheduler { | ||||
|             )); | ||||
|             let index = self.index(uid)?; | ||||
|             let mut index_wtxn = index.write_txn()?; | ||||
|             let regen_stats = | ||||
|                 milli::update::upgrade::upgrade(&mut index_wtxn, &index, progress.clone()) | ||||
|                     .map_err(|e| Error::from_milli(e, Some(uid.to_string())))?; | ||||
|             let regen_stats = milli::update::upgrade::upgrade( | ||||
|                 &mut index_wtxn, | ||||
|                 &index, | ||||
|                 db_version, | ||||
|                 progress.clone(), | ||||
|             ) | ||||
|             .map_err(|e| Error::from_milli(e, Some(uid.to_string())))?; | ||||
|             if regen_stats { | ||||
|                 let stats = crate::index_mapper::IndexStats::new(&index, &index_wtxn) | ||||
|                     .map_err(|e| Error::from_milli(e, Some(uid.to_string())))?; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user