From c8832409ad059e31ee2e6b837c2530a6dd42a684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Fri, 22 Nov 2019 13:22:35 +0100 Subject: [PATCH 1/3] Fix the dead lock on index deletion once again --- meilidb-core/src/database.rs | 21 +++++++++++++++------ meilidb-core/src/store/mod.rs | 5 +---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/meilidb-core/src/database.rs b/meilidb-core/src/database.rs index b6c9f47ef..894193fa2 100644 --- a/meilidb-core/src/database.rs +++ b/meilidb-core/src/database.rs @@ -18,7 +18,7 @@ pub struct Database { pub env: heed::Env, common_store: heed::PolyDatabase, indexes_store: heed::Database, - indexes: RwLock)>>, + indexes: RwLock>)>>, update_fn: Arc, } @@ -36,7 +36,7 @@ macro_rules! r#break_try { pub enum UpdateEvent { NewUpdate, - MustStop, + MustClear, } pub type UpdateEvents = Receiver; @@ -48,7 +48,7 @@ fn update_awaiter( index_uid: &str, update_fn: Arc, index: Index, -) { +) -> MResult<()> { let mut receiver = receiver.into_iter(); while let Some(UpdateEvent::NewUpdate) = receiver.next() { loop { @@ -97,6 +97,14 @@ fn update_awaiter( } debug!("update loop system stopped"); + + let mut writer = env.write_txn()?; + store::clear(&mut writer, &index)?; + writer.commit()?; + + debug!("store {} cleared", index_uid); + + Ok(()) } impl Database { @@ -226,14 +234,15 @@ impl Database { // and clear all the LMDB dbi let mut writer = self.env.write_txn()?; self.indexes_store.delete(&mut writer, &name)?; - - store::clear(&mut writer, &index)?; writer.commit()?; + // send a stop event to the update loop of the index + index.updates_notifier.send(UpdateEvent::MustClear).unwrap(); + drop(indexes_lock); // join the update loop thread to ensure it is stopped - handle.join().unwrap(); + handle.join().unwrap()?; Ok(true) } diff --git a/meilidb-core/src/store/mod.rs b/meilidb-core/src/store/mod.rs index 39392b762..4ba93e10e 100644 --- a/meilidb-core/src/store/mod.rs +++ b/meilidb-core/src/store/mod.rs @@ -92,7 +92,7 @@ pub struct Index { pub updates: Updates, pub updates_results: UpdatesResults, - updates_notifier: UpdateEventsEmitter, + pub(crate) updates_notifier: UpdateEventsEmitter, } impl Index { @@ -381,9 +381,6 @@ pub fn open( } pub fn clear(writer: &mut heed::RwTxn, index: &Index) -> MResult<()> { - // send a stop event to the update loop of the index - index.updates_notifier.send(UpdateEvent::MustStop).unwrap(); - // clear all the stores index.main.clear(writer)?; index.postings_lists.clear(writer)?; From d4d2a2303a10032e9bb8e35c8d6f894856cd6876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Fri, 22 Nov 2019 13:23:48 +0100 Subject: [PATCH 2/3] Fix a typo on timeout_ms used for multi index search --- meilidb-http/src/routes/search.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meilidb-http/src/routes/search.rs b/meilidb-http/src/routes/search.rs index d94958bc2..e298feecb 100644 --- a/meilidb-http/src/routes/search.rs +++ b/meilidb-http/src/routes/search.rs @@ -202,7 +202,7 @@ pub async fn search_multi_index(mut ctx: Context) -> SResult { search_builder.filters(filters); } if let Some(timeout_ms) = par_body.timeout_ms { - search_builder.timeout(Duration::from_secs(timeout_ms)); + search_builder.timeout(Duration::from_millis(timeout_ms)); } if let Some(matches) = par_body.matches { if matches { From f241c999adfc4a6cd19231042063e2ecacfbfe59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Fri, 22 Nov 2019 11:43:02 +0100 Subject: [PATCH 3/3] Make the CI use rust stable --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f028ebe44..e1dc6fd9f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,7 +12,7 @@ jobs: container: tpayet/chiquitita:latest steps: - script: | - curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly + curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable $HOME/.cargo/bin/rustup component add rustfmt displayName: 'Install rustc and components' - script: | @@ -34,7 +34,7 @@ jobs: container: tpayet/chiquitita:latest steps: - script: | - curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly + curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable $HOME/.cargo/bin/rustup component add rustfmt displayName: 'Install rustc and components' - script: |