mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-22 21:04:27 +01:00
create dump v5
This commit is contained in:
parent
4778884105
commit
61035a3ea4
@ -24,7 +24,7 @@ enum TaskType {
|
|||||||
DocumentDeletion,
|
DocumentDeletion,
|
||||||
SettingsUpdate,
|
SettingsUpdate,
|
||||||
ClearAll,
|
ClearAll,
|
||||||
Dump,
|
DumpCreation,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<TaskContent> for TaskType {
|
impl From<TaskContent> for TaskType {
|
||||||
@ -44,7 +44,7 @@ impl From<TaskContent> for TaskType {
|
|||||||
TaskContent::IndexDeletion => TaskType::IndexDeletion,
|
TaskContent::IndexDeletion => TaskType::IndexDeletion,
|
||||||
TaskContent::IndexCreation { .. } => TaskType::IndexCreation,
|
TaskContent::IndexCreation { .. } => TaskType::IndexCreation,
|
||||||
TaskContent::IndexUpdate { .. } => TaskType::IndexUpdate,
|
TaskContent::IndexUpdate { .. } => TaskType::IndexUpdate,
|
||||||
TaskContent::Dump { .. } => TaskType::Dump,
|
TaskContent::Dump { .. } => TaskType::DumpCreation,
|
||||||
_ => unreachable!("unexpected task type"),
|
_ => unreachable!("unexpected task type"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,9 +220,10 @@ impl From<Task> for TaskView {
|
|||||||
TaskType::IndexUpdate,
|
TaskType::IndexUpdate,
|
||||||
Some(TaskDetails::IndexInfo { primary_key }),
|
Some(TaskDetails::IndexInfo { primary_key }),
|
||||||
),
|
),
|
||||||
TaskContent::Dump { uid } => {
|
TaskContent::Dump { uid } => (
|
||||||
(TaskType::Dump, Some(TaskDetails::Dump { dump_uid: uid }))
|
TaskType::DumpCreation,
|
||||||
}
|
Some(TaskDetails::Dump { dump_uid: uid }),
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
// An event always has at least one event: "Created"
|
// An event always has at least one event: "Created"
|
||||||
|
@ -66,6 +66,7 @@ pub fn load_dump(
|
|||||||
index_db_size,
|
index_db_size,
|
||||||
meta_env_size,
|
meta_env_size,
|
||||||
indexing_options,
|
indexing_options,
|
||||||
|
"V5",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,10 +19,11 @@ pub fn load_dump(
|
|||||||
index_db_size: usize,
|
index_db_size: usize,
|
||||||
meta_env_size: usize,
|
meta_env_size: usize,
|
||||||
indexing_options: &IndexerOpts,
|
indexing_options: &IndexerOpts,
|
||||||
|
version: &str,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
info!(
|
info!(
|
||||||
"Loading dump from {}, dump database version: {}, dump version: V4",
|
"Loading dump from {}, dump database version: {}, dump version: {}",
|
||||||
meta.dump_date, meta.db_version
|
meta.dump_date, meta.db_version, version
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut options = EnvOpenOptions::new();
|
let mut options = EnvOpenOptions::new();
|
||||||
|
@ -69,6 +69,8 @@ pub enum MetadataVersion {
|
|||||||
V2(Metadata),
|
V2(Metadata),
|
||||||
V3(Metadata),
|
V3(Metadata),
|
||||||
V4(Metadata),
|
V4(Metadata),
|
||||||
|
// V5 is forward compatible with V4 but not backward compatible.
|
||||||
|
V5(Metadata),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MetadataVersion {
|
impl MetadataVersion {
|
||||||
@ -80,6 +82,7 @@ impl MetadataVersion {
|
|||||||
meta_env_size: usize,
|
meta_env_size: usize,
|
||||||
indexing_options: &IndexerOpts,
|
indexing_options: &IndexerOpts,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
|
let version = self.version();
|
||||||
match self {
|
match self {
|
||||||
MetadataVersion::V1(_meta) => {
|
MetadataVersion::V1(_meta) => {
|
||||||
anyhow::bail!("The version 1 of the dumps is not supported anymore. You can re-export your dump from a version between 0.21 and 0.24, or start fresh from a version 0.25 onwards.")
|
anyhow::bail!("The version 1 of the dumps is not supported anymore. You can re-export your dump from a version between 0.21 and 0.24, or start fresh from a version 0.25 onwards.")
|
||||||
@ -100,46 +103,49 @@ impl MetadataVersion {
|
|||||||
meta_env_size,
|
meta_env_size,
|
||||||
indexing_options,
|
indexing_options,
|
||||||
)?,
|
)?,
|
||||||
MetadataVersion::V4(meta) => v4::load_dump(
|
MetadataVersion::V4(meta) | MetadataVersion::V5(meta) => v4::load_dump(
|
||||||
meta,
|
meta,
|
||||||
src,
|
src,
|
||||||
dst,
|
dst,
|
||||||
index_db_size,
|
index_db_size,
|
||||||
meta_env_size,
|
meta_env_size,
|
||||||
indexing_options,
|
indexing_options,
|
||||||
|
version,
|
||||||
)?,
|
)?,
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_v4(index_db_size: usize, update_db_size: usize) -> Self {
|
pub fn new_v5(index_db_size: usize, update_db_size: usize) -> Self {
|
||||||
let meta = Metadata::new(index_db_size, update_db_size);
|
let meta = Metadata::new(index_db_size, update_db_size);
|
||||||
Self::V4(meta)
|
Self::V5(meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn db_version(&self) -> &str {
|
pub fn db_version(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
Self::V1(meta) => &meta.db_version,
|
Self::V1(meta) => &meta.db_version,
|
||||||
Self::V2(meta) | Self::V3(meta) | Self::V4(meta) => &meta.db_version,
|
Self::V2(meta) | Self::V3(meta) | Self::V4(meta) | Self::V5(meta) => &meta.db_version,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn version(&self) -> &str {
|
pub fn version(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
MetadataVersion::V1(_) => "V1",
|
MetadataVersion::V1(_) => "V1",
|
||||||
MetadataVersion::V2(_) => "V2",
|
MetadataVersion::V2(_) => "V2",
|
||||||
MetadataVersion::V3(_) => "V3",
|
MetadataVersion::V3(_) => "V3",
|
||||||
MetadataVersion::V4(_) => "V4",
|
MetadataVersion::V4(_) => "V4",
|
||||||
|
MetadataVersion::V5(_) => "V5",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dump_date(&self) -> Option<&OffsetDateTime> {
|
pub fn dump_date(&self) -> Option<&OffsetDateTime> {
|
||||||
match self {
|
match self {
|
||||||
MetadataVersion::V1(_) => None,
|
MetadataVersion::V1(_) => None,
|
||||||
MetadataVersion::V2(meta) | MetadataVersion::V3(meta) | MetadataVersion::V4(meta) => {
|
MetadataVersion::V2(meta)
|
||||||
Some(&meta.dump_date)
|
| MetadataVersion::V3(meta)
|
||||||
}
|
| MetadataVersion::V4(meta)
|
||||||
|
| MetadataVersion::V5(meta) => Some(&meta.dump_date),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -294,7 +300,7 @@ where
|
|||||||
let temp_dump_dir = tokio::task::spawn_blocking(tempfile::TempDir::new).await??;
|
let temp_dump_dir = tokio::task::spawn_blocking(tempfile::TempDir::new).await??;
|
||||||
let temp_dump_path = temp_dump_dir.path().to_owned();
|
let temp_dump_path = temp_dump_dir.path().to_owned();
|
||||||
|
|
||||||
let meta = MetadataVersion::new_v4(self.index_db_size, self.task_store_size);
|
let meta = MetadataVersion::new_v5(self.index_db_size, self.task_store_size);
|
||||||
let meta_path = temp_dump_path.join(META_FILE_NAME);
|
let meta_path = temp_dump_path.join(META_FILE_NAME);
|
||||||
let mut meta_file = File::create(&meta_path)?;
|
let mut meta_file = File::create(&meta_path)?;
|
||||||
serde_json::to_writer(&mut meta_file, &meta)?;
|
serde_json::to_writer(&mut meta_file, &meta)?;
|
||||||
@ -306,11 +312,11 @@ where
|
|||||||
AuthController::dump(&self.db_path, &temp_dump_path)?;
|
AuthController::dump(&self.db_path, &temp_dump_path)?;
|
||||||
TaskStore::dump(
|
TaskStore::dump(
|
||||||
self.env.clone(),
|
self.env.clone(),
|
||||||
&self.dump_path,
|
&temp_dump_path,
|
||||||
self.update_file_store.clone(),
|
self.update_file_store.clone(),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
self.index_resolver.dump(&self.dump_path).await?;
|
self.index_resolver.dump(&temp_dump_path).await?;
|
||||||
|
|
||||||
let dump_path = self.dump_path.clone();
|
let dump_path = self.dump_path.clone();
|
||||||
let dump_path = tokio::task::spawn_blocking(move || -> Result<PathBuf> {
|
let dump_path = tokio::task::spawn_blocking(move || -> Result<PathBuf> {
|
||||||
|
Loading…
Reference in New Issue
Block a user