From c063f154fbd509bae083a4c020a74faba0ef1286 Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Tue, 25 Oct 2022 10:53:25 +0200 Subject: [PATCH] Add the snapshots directory path to the IndexScheduler --- index-scheduler/src/insta_snapshot.rs | 1 + index-scheduler/src/lib.rs | 12 ++++++++++-- meilisearch-http/src/lib.rs | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/index-scheduler/src/insta_snapshot.rs b/index-scheduler/src/insta_snapshot.rs index 49d0ab76d..8f0b6129f 100644 --- a/index-scheduler/src/insta_snapshot.rs +++ b/index-scheduler/src/insta_snapshot.rs @@ -26,6 +26,7 @@ pub fn snapshot_index_scheduler(scheduler: &IndexScheduler) -> String { index_mapper, wake_up: _, dumps_path: _, + snapshots_path: _, test_breakpoint_sdr: _, planned_failures: _, run_loop_iteration: _, diff --git a/index-scheduler/src/lib.rs b/index-scheduler/src/lib.rs index 05fb59385..010aeb238 100644 --- a/index-scheduler/src/lib.rs +++ b/index-scheduler/src/lib.rs @@ -242,6 +242,9 @@ pub struct IndexScheduler { /// The path used to create the dumps. pub(crate) dumps_path: PathBuf, + /// The path used to create the snapshots. + pub(crate) snapshots_path: PathBuf, + // ================= test // The next entry is dedicated to the tests. /// Provide a way to set a breakpoint in multiple part of the scheduler. @@ -261,8 +264,8 @@ pub struct IndexScheduler { run_loop_iteration: Arc>, } impl IndexScheduler { - fn private_clone(&self) -> Self { - Self { + fn private_clone(&self) -> IndexScheduler { + IndexScheduler { env: self.env.clone(), must_stop_processing: self.must_stop_processing.clone(), processing_tasks: self.processing_tasks.clone(), @@ -277,6 +280,7 @@ impl IndexScheduler { index_mapper: self.index_mapper.clone(), wake_up: self.wake_up.clone(), autobatching_enabled: self.autobatching_enabled, + snapshots_path: self.snapshots_path.clone(), dumps_path: self.dumps_path.clone(), #[cfg(test)] test_breakpoint_sdr: self.test_breakpoint_sdr.clone(), @@ -308,6 +312,7 @@ impl IndexScheduler { /// - `tasks_path`: the path to the folder containing the task databases /// - `update_file_path`: the path to the file store containing the files associated to the tasks /// - `indexes_path`: the path to the folder containing meilisearch's indexes + /// - `snapshots_path`: the path to the folder containing the snapshots /// - `dumps_path`: the path to the folder containing the dumps /// - `index_size`: the maximum size, in bytes, of each meilisearch index /// - `indexer_config`: configuration used during indexing for each meilisearch index @@ -319,6 +324,7 @@ impl IndexScheduler { update_file_path: PathBuf, indexes_path: PathBuf, dumps_path: PathBuf, + snapshots_path: PathBuf, task_db_size: usize, index_size: usize, indexer_config: IndexerConfig, @@ -356,6 +362,7 @@ impl IndexScheduler { wake_up: Arc::new(SignalEvent::auto(true)), autobatching_enabled, dumps_path, + snapshots_path, #[cfg(test)] test_breakpoint_sdr, @@ -963,6 +970,7 @@ mod tests { tempdir.path().join("db_path"), tempdir.path().join("file_store"), tempdir.path().join("indexes"), + tempdir.path().join("snapshots"), tempdir.path().join("dumps"), 1024 * 1024, 1024 * 1024, diff --git a/meilisearch-http/src/lib.rs b/meilisearch-http/src/lib.rs index 59a747782..656e7460a 100644 --- a/meilisearch-http/src/lib.rs +++ b/meilisearch-http/src/lib.rs @@ -113,6 +113,7 @@ pub fn setup_meilisearch(opt: &Opt) -> anyhow::Result<(IndexScheduler, AuthContr opt.db_path.join("tasks"), opt.db_path.join("update_files"), opt.db_path.join("indexes"), + opt.snapshot_dir.clone(), opt.dumps_dir.clone(), opt.max_task_db_size.get_bytes() as usize, opt.max_index_size.get_bytes() as usize,