Merge branch 'stable'

This commit is contained in:
Clément Renault 2020-09-11 12:08:20 +02:00
commit 84a3e95fa4
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4
9 changed files with 54 additions and 27 deletions

View File

@ -1,3 +1,7 @@
## v0.14.1
- Fix version mismatch in snapshot importation (#959)
## v0.14.0 ## v0.14.0
- Fix facet distribution case (#797) - Fix facet distribution case (#797)

12
Cargo.lock generated
View File

@ -1493,7 +1493,7 @@ checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
[[package]] [[package]]
name = "meilisearch-core" name = "meilisearch-core"
version = "0.14.0" version = "0.14.1"
dependencies = [ dependencies = [
"arc-swap", "arc-swap",
"assert_matches", "assert_matches",
@ -1540,14 +1540,14 @@ dependencies = [
[[package]] [[package]]
name = "meilisearch-error" name = "meilisearch-error"
version = "0.14.0" version = "0.14.1"
dependencies = [ dependencies = [
"actix-http", "actix-http",
] ]
[[package]] [[package]]
name = "meilisearch-http" name = "meilisearch-http"
version = "0.14.0" version = "0.14.1"
dependencies = [ dependencies = [
"actix-cors", "actix-cors",
"actix-http", "actix-http",
@ -1596,7 +1596,7 @@ dependencies = [
[[package]] [[package]]
name = "meilisearch-schema" name = "meilisearch-schema"
version = "0.14.0" version = "0.14.1"
dependencies = [ dependencies = [
"indexmap", "indexmap",
"meilisearch-error", "meilisearch-error",
@ -1607,7 +1607,7 @@ dependencies = [
[[package]] [[package]]
name = "meilisearch-tokenizer" name = "meilisearch-tokenizer"
version = "0.14.0" version = "0.14.1"
dependencies = [ dependencies = [
"deunicode", "deunicode",
"slice-group-by", "slice-group-by",
@ -1615,7 +1615,7 @@ dependencies = [
[[package]] [[package]]
name = "meilisearch-types" name = "meilisearch-types"
version = "0.14.0" version = "0.14.1"
dependencies = [ dependencies = [
"serde", "serde",
"zerocopy", "zerocopy",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "meilisearch-core" name = "meilisearch-core"
version = "0.14.0" version = "0.14.1"
license = "MIT" license = "MIT"
authors = ["Kerollmops <clement@meilisearch.com>"] authors = ["Kerollmops <clement@meilisearch.com>"]
edition = "2018" edition = "2018"
@ -24,10 +24,10 @@ intervaltree = "0.2.5"
itertools = "0.9.0" itertools = "0.9.0"
levenshtein_automata = { version = "0.2.0", features = ["fst_automaton"] } levenshtein_automata = { version = "0.2.0", features = ["fst_automaton"] }
log = "0.4.8" log = "0.4.8"
meilisearch-error = { path = "../meilisearch-error", version = "0.14.0" } meilisearch-error = { path = "../meilisearch-error", version = "0.14.1" }
meilisearch-schema = { path = "../meilisearch-schema", version = "0.14.0" } meilisearch-schema = { path = "../meilisearch-schema", version = "0.14.1" }
meilisearch-tokenizer = { path = "../meilisearch-tokenizer", version = "0.14.0" } meilisearch-tokenizer = { path = "../meilisearch-tokenizer", version = "0.14.1" }
meilisearch-types = { path = "../meilisearch-types", version = "0.14.0" } meilisearch-types = { path = "../meilisearch-types", version = "0.14.1" }
once_cell = "1.3.1" once_cell = "1.3.1"
ordered-float = { version = "1.0.2", features = ["serde"] } ordered-float = { version = "1.0.2", features = ["serde"] }
pest = { git = "https://github.com/MarinPostma/pest.git", tag = "meilisearch-patch1" } pest = { git = "https://github.com/MarinPostma/pest.git", tag = "meilisearch-patch1" }

View File

@ -40,6 +40,7 @@ pub struct Database {
indexes_store: heed::Database<Str, Unit>, indexes_store: heed::Database<Str, Unit>,
indexes: RwLock<HashMap<String, (Index, thread::JoinHandle<MResult<()>>)>>, indexes: RwLock<HashMap<String, (Index, thread::JoinHandle<MResult<()>>)>>,
update_fn: Arc<ArcSwapFn>, update_fn: Arc<ArcSwapFn>,
database_version: (u32, u32, u32),
} }
pub struct DatabaseOptions { pub struct DatabaseOptions {
@ -165,7 +166,7 @@ fn update_awaiter(
/// Ensures Meilisearch version is compatible with the database, returns an error versions mismatch. /// Ensures Meilisearch version is compatible with the database, returns an error versions mismatch.
/// If create is set to true, a VERSION file is created with the current version. /// If create is set to true, a VERSION file is created with the current version.
fn version_guard(path: &Path, create: bool) -> MResult<()> { fn version_guard(path: &Path, create: bool) -> MResult<(u32, u32, u32)> {
let current_version_major = env!("CARGO_PKG_VERSION_MAJOR"); let current_version_major = env!("CARGO_PKG_VERSION_MAJOR");
let current_version_minor = env!("CARGO_PKG_VERSION_MINOR"); let current_version_minor = env!("CARGO_PKG_VERSION_MINOR");
let current_version_patch = env!("CARGO_PKG_VERSION_PATCH"); let current_version_patch = env!("CARGO_PKG_VERSION_PATCH");
@ -186,9 +187,16 @@ fn version_guard(path: &Path, create: bool) -> MResult<()> {
// the first is always the complete match, safe to unwrap because we have a match // the first is always the complete match, safe to unwrap because we have a match
let version_major = version.get(1).unwrap().as_str(); let version_major = version.get(1).unwrap().as_str();
let version_minor = version.get(2).unwrap().as_str(); let version_minor = version.get(2).unwrap().as_str();
let version_patch = version.get(3).unwrap().as_str();
if version_major != current_version_major || version_minor != current_version_minor { if version_major != current_version_major || version_minor != current_version_minor {
return Err(Error::VersionMismatch(format!("{}.{}.XX", version_major, version_minor))); Err(Error::VersionMismatch(format!("{}.{}.XX", version_major, version_minor)))
} else {
Ok((
version_major.parse().or_else(|e| Err(Error::VersionMismatch(format!("error parsing database version: {}", e))))?,
version_minor.parse().or_else(|e| Err(Error::VersionMismatch(format!("error parsing database version: {}", e))))?,
version_patch.parse().or_else(|e| Err(Error::VersionMismatch(format!("error parsing database version: {}", e))))?
))
} }
} }
Err(error) => { Err(error) => {
@ -202,17 +210,22 @@ fn version_guard(path: &Path, create: bool) -> MResult<()> {
current_version_major, current_version_major,
current_version_minor, current_version_minor,
current_version_patch).as_bytes())?; current_version_patch).as_bytes())?;
Ok((
current_version_major.parse().or_else(|e| Err(Error::VersionMismatch(format!("error parsing database version: {}", e))))?,
current_version_minor.parse().or_else(|e| Err(Error::VersionMismatch(format!("error parsing database version: {}", e))))?,
current_version_patch.parse().or_else(|e| Err(Error::VersionMismatch(format!("error parsing database version: {}", e))))?
))
} else { } else {
// when no version file is found and we were not told to create one, this // when no version file is found and we were not told to create one, this
// means that the version is inferior to the one this feature was added in. // means that the version is inferior to the one this feature was added in.
return Err(Error::VersionMismatch("<0.12.0".to_string())); Err(Error::VersionMismatch("<0.12.0".to_string()))
} }
} }
_ => return Err(error.into()) _ => Err(error.into())
} }
} }
} }
Ok(())
} }
impl Database { impl Database {
@ -224,7 +237,7 @@ impl Database {
fs::create_dir_all(&path)?; fs::create_dir_all(&path)?;
// create file only if main db wasn't created before (first run) // create file only if main db wasn't created before (first run)
version_guard(path.as_ref(), !main_path.exists() && !update_path.exists())?; let database_version = version_guard(path.as_ref(), !main_path.exists() && !update_path.exists())?;
fs::create_dir_all(&main_path)?; fs::create_dir_all(&main_path)?;
let env = heed::EnvOpenOptions::new() let env = heed::EnvOpenOptions::new()
@ -302,6 +315,7 @@ impl Database {
indexes_store, indexes_store,
indexes: RwLock::new(indexes), indexes: RwLock::new(indexes),
update_fn, update_fn,
database_version,
}) })
} }
@ -469,9 +483,18 @@ impl Database {
let env_path = path.join("main"); let env_path = path.join("main");
let env_update_path = path.join("update"); let env_update_path = path.join("update");
let env_version_path = path.join("VERSION");
fs::create_dir(&env_path)?; fs::create_dir(&env_path)?;
fs::create_dir(&env_update_path)?; fs::create_dir(&env_update_path)?;
// write Database Version
let (current_version_major, current_version_minor, current_version_patch) = self.database_version;
let mut version_file = File::create(&env_version_path)?;
version_file.write_all(format!("{}.{}.{}",
current_version_major,
current_version_minor,
current_version_patch).as_bytes())?;
let env_path = env_path.join("data.mdb"); let env_path = env_path.join("data.mdb");
let env_file = self.env.copy_to_path(&env_path, CompactionOption::Enabled)?; let env_file = self.env.copy_to_path(&env_path, CompactionOption::Enabled)?;

View File

@ -1,6 +1,6 @@
[package] [package]
name = "meilisearch-error" name = "meilisearch-error"
version = "0.14.0" version = "0.14.1"
authors = ["marin <postma.marin@protonmail.com>"] authors = ["marin <postma.marin@protonmail.com>"]
edition = "2018" edition = "2018"

View File

@ -1,7 +1,7 @@
[package] [package]
name = "meilisearch-http" name = "meilisearch-http"
description = "MeiliSearch HTTP server" description = "MeiliSearch HTTP server"
version = "0.14.0" version = "0.14.1"
license = "MIT" license = "MIT"
authors = [ authors = [
"Quentin de Quelen <quentin@dequelen.me>", "Quentin de Quelen <quentin@dequelen.me>",
@ -33,10 +33,10 @@ http = "0.1.19"
indexmap = { version = "1.3.2", features = ["serde-1"] } indexmap = { version = "1.3.2", features = ["serde-1"] }
log = "0.4.8" log = "0.4.8"
main_error = "0.1.0" main_error = "0.1.0"
meilisearch-core = { path = "../meilisearch-core", version = "0.14.0" } meilisearch-core = { path = "../meilisearch-core", version = "0.14.1" }
meilisearch-error = { path = "../meilisearch-error", version = "0.14.0" } meilisearch-error = { path = "../meilisearch-error", version = "0.14.1" }
meilisearch-schema = { path = "../meilisearch-schema", version = "0.14.0" } meilisearch-schema = { path = "../meilisearch-schema", version = "0.14.1" }
meilisearch-tokenizer = {path = "../meilisearch-tokenizer", version = "0.14.0"} meilisearch-tokenizer = {path = "../meilisearch-tokenizer", version = "0.14.1"}
mime = "0.3.16" mime = "0.3.16"
rand = "0.7.3" rand = "0.7.3"
regex = "1.3.6" regex = "1.3.6"

View File

@ -1,13 +1,13 @@
[package] [package]
name = "meilisearch-schema" name = "meilisearch-schema"
version = "0.14.0" version = "0.14.1"
license = "MIT" license = "MIT"
authors = ["Kerollmops <renault.cle@gmail.com>"] authors = ["Kerollmops <renault.cle@gmail.com>"]
edition = "2018" edition = "2018"
[dependencies] [dependencies]
indexmap = { version = "1.3.2", features = ["serde-1"] } indexmap = { version = "1.3.2", features = ["serde-1"] }
meilisearch-error = { path = "../meilisearch-error", version = "0.14.0" } meilisearch-error = { path = "../meilisearch-error", version = "0.14.1" }
serde = { version = "1.0.105", features = ["derive"] } serde = { version = "1.0.105", features = ["derive"] }
serde_json = { version = "1.0.50", features = ["preserve_order"] } serde_json = { version = "1.0.50", features = ["preserve_order"] }
zerocopy = "0.3.0" zerocopy = "0.3.0"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "meilisearch-tokenizer" name = "meilisearch-tokenizer"
version = "0.14.0" version = "0.14.1"
license = "MIT" license = "MIT"
authors = ["Kerollmops <renault.cle@gmail.com>"] authors = ["Kerollmops <renault.cle@gmail.com>"]
edition = "2018" edition = "2018"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "meilisearch-types" name = "meilisearch-types"
version = "0.14.0" version = "0.14.1"
license = "MIT" license = "MIT"
authors = ["Clément Renault <renault.cle@gmail.com>"] authors = ["Clément Renault <renault.cle@gmail.com>"]
edition = "2018" edition = "2018"