mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 20:07:09 +02:00
write and load the user-id in the dumps
This commit is contained in:
parent
ba14ea1243
commit
87a8bf5e96
9 changed files with 51 additions and 13 deletions
|
@ -22,6 +22,7 @@ pub struct DumpActor<U, I> {
|
|||
index_resolver: Arc<IndexResolver<U, I>>,
|
||||
update: UpdateSender,
|
||||
dump_path: PathBuf,
|
||||
analytics_path: PathBuf,
|
||||
lock: Arc<Mutex<()>>,
|
||||
dump_infos: Arc<RwLock<HashMap<String, DumpInfo>>>,
|
||||
update_db_size: usize,
|
||||
|
@ -43,6 +44,7 @@ where
|
|||
index_resolver: Arc<IndexResolver<U, I>>,
|
||||
update: UpdateSender,
|
||||
dump_path: impl AsRef<Path>,
|
||||
analytics_path: impl AsRef<Path>,
|
||||
index_db_size: usize,
|
||||
update_db_size: usize,
|
||||
) -> Self {
|
||||
|
@ -53,6 +55,7 @@ where
|
|||
index_resolver,
|
||||
update,
|
||||
dump_path: dump_path.as_ref().into(),
|
||||
analytics_path: analytics_path.as_ref().into(),
|
||||
dump_infos,
|
||||
lock,
|
||||
index_db_size,
|
||||
|
@ -119,6 +122,7 @@ where
|
|||
|
||||
let task = DumpTask {
|
||||
path: self.dump_path.clone(),
|
||||
analytics_path: self.analytics_path.clone(),
|
||||
index_resolver: self.index_resolver.clone(),
|
||||
update_sender: self.update.clone(),
|
||||
uid: uid.clone(),
|
||||
|
|
|
@ -33,6 +33,7 @@ impl DumpActorHandle for DumpActorHandleImpl {
|
|||
impl DumpActorHandleImpl {
|
||||
pub fn new(
|
||||
path: impl AsRef<Path>,
|
||||
analytics_path: impl AsRef<Path>,
|
||||
index_resolver: Arc<HardStateIndexResolver>,
|
||||
update: crate::index_controller::updates::UpdateSender,
|
||||
index_db_size: usize,
|
||||
|
@ -44,6 +45,7 @@ impl DumpActorHandleImpl {
|
|||
index_resolver,
|
||||
update,
|
||||
path,
|
||||
analytics_path,
|
||||
index_db_size,
|
||||
update_db_size,
|
||||
);
|
||||
|
|
|
@ -2,6 +2,7 @@ use std::path::Path;
|
|||
|
||||
use log::info;
|
||||
|
||||
use crate::analytics;
|
||||
use crate::index_controller::dump_actor::Metadata;
|
||||
use crate::index_controller::index_resolver::IndexResolver;
|
||||
use crate::index_controller::update_file_store::UpdateFileStore;
|
||||
|
@ -24,6 +25,7 @@ pub fn load_dump(
|
|||
IndexResolver::load_dump(src.as_ref(), &dst, index_db_size, indexing_options)?;
|
||||
UpdateFileStore::load_dump(src.as_ref(), &dst)?;
|
||||
UpdateStore::load_dump(&src, &dst, update_db_size)?;
|
||||
analytics::load_dump(src.as_ref(), dst.as_ref());
|
||||
|
||||
info!("Loading indexes.");
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ use super::index_resolver::index_store::IndexStore;
|
|||
use super::index_resolver::uuid_store::UuidStore;
|
||||
use super::index_resolver::IndexResolver;
|
||||
use super::updates::UpdateSender;
|
||||
use crate::analytics;
|
||||
use crate::compression::{from_tar_gz, to_tar_gz};
|
||||
use crate::index_controller::dump_actor::error::DumpActorError;
|
||||
use crate::index_controller::dump_actor::loaders::{v2, v3};
|
||||
|
@ -223,6 +224,7 @@ pub fn load_dump(
|
|||
|
||||
struct DumpTask<U, I> {
|
||||
path: PathBuf,
|
||||
analytics_path: PathBuf,
|
||||
index_resolver: Arc<IndexResolver<U, I>>,
|
||||
update_sender: UpdateSender,
|
||||
uid: String,
|
||||
|
@ -247,6 +249,7 @@ where
|
|||
let meta_path = temp_dump_path.join(META_FILE_NAME);
|
||||
let mut meta_file = File::create(&meta_path)?;
|
||||
serde_json::to_writer(&mut meta_file, &meta)?;
|
||||
analytics::write_dump(&self.analytics_path, &temp_dump_path.join("user-id"));
|
||||
|
||||
create_dir_all(&temp_dump_path.join("indexes")).await?;
|
||||
let uuids = self.index_resolver.dump(temp_dump_path.clone()).await?;
|
||||
|
@ -339,6 +342,8 @@ mod test {
|
|||
|
||||
let task = DumpTask {
|
||||
path: tmp.path().to_owned(),
|
||||
// this should do nothing
|
||||
analytics_path: tmp.path().join("user-id"),
|
||||
index_resolver,
|
||||
update_sender,
|
||||
uid: String::from("test"),
|
||||
|
@ -367,6 +372,8 @@ mod test {
|
|||
|
||||
let task = DumpTask {
|
||||
path: tmp.path().to_owned(),
|
||||
// this should do nothing
|
||||
analytics_path: tmp.path().join("user-id"),
|
||||
index_resolver,
|
||||
update_sender,
|
||||
uid: String::from("test"),
|
||||
|
|
|
@ -169,8 +169,10 @@ impl IndexControllerBuilder {
|
|||
let dump_path = self
|
||||
.dump_dst
|
||||
.ok_or_else(|| anyhow::anyhow!("Missing dump directory path"))?;
|
||||
let analytics_path = db_path.as_ref().join("user-id");
|
||||
let dump_handle = dump_actor::DumpActorHandleImpl::new(
|
||||
dump_path,
|
||||
analytics_path,
|
||||
index_resolver.clone(),
|
||||
update_sender.clone(),
|
||||
index_size,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue