From 3ef0830c5dcde12066c9a489b9c441e6717c541f Mon Sep 17 00:00:00 2001 From: mpostma Date: Thu, 10 Jun 2021 15:55:44 +0200 Subject: [PATCH] review changes --- meilisearch-http/src/index/update_handler.rs | 2 +- meilisearch-http/src/index/updates.rs | 2 +- meilisearch-http/src/index_controller/index_actor/store.rs | 2 ++ meilisearch-http/src/index_controller/mod.rs | 2 +- .../src/index_controller/update_actor/store/mod.rs | 6 +++--- meilisearch-http/src/index_controller/updates.rs | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/meilisearch-http/src/index/update_handler.rs b/meilisearch-http/src/index/update_handler.rs index 13e516d3c..63a074abb 100644 --- a/meilisearch-http/src/index/update_handler.rs +++ b/meilisearch-http/src/index/update_handler.rs @@ -81,7 +81,7 @@ impl UpdateHandler { primary_key.as_deref(), ), ClearDocuments => index.clear_documents(update_builder), - DeleteDocuments { documents } => index.delete_documents(documents.to_vec(), update_builder), + DeleteDocuments { ids } => index.delete_documents(ids, update_builder), Settings(settings) => index.update_settings(&settings.clone().check(), update_builder), }; diff --git a/meilisearch-http/src/index/updates.rs b/meilisearch-http/src/index/updates.rs index 750e1f275..9ed4fe49e 100644 --- a/meilisearch-http/src/index/updates.rs +++ b/meilisearch-http/src/index/updates.rs @@ -298,7 +298,7 @@ impl Index { pub fn delete_documents( &self, - document_ids: Vec, + document_ids: &[String], update_builder: UpdateBuilder, ) -> anyhow::Result { let mut txn = self.write_txn()?; diff --git a/meilisearch-http/src/index_controller/index_actor/store.rs b/meilisearch-http/src/index_controller/index_actor/store.rs index 9b6b057c3..1646821d8 100644 --- a/meilisearch-http/src/index_controller/index_actor/store.rs +++ b/meilisearch-http/src/index_controller/index_actor/store.rs @@ -40,6 +40,8 @@ impl MapIndexStore { #[async_trait::async_trait] impl IndexStore for MapIndexStore { async fn create(&self, uuid: Uuid, primary_key: Option) -> IndexResult { + // We need to keep the lock until we are sure the db file has been opened correclty, to + // ensure that another db is not created at the same time. let mut lock = self.index_store.write().await; if let Some(index) = lock.get(&uuid) { diff --git a/meilisearch-http/src/index_controller/mod.rs b/meilisearch-http/src/index_controller/mod.rs index 3c46e48f6..0c801558b 100644 --- a/meilisearch-http/src/index_controller/mod.rs +++ b/meilisearch-http/src/index_controller/mod.rs @@ -203,7 +203,7 @@ impl IndexController { documents: Vec, ) -> anyhow::Result { let uuid = self.uuid_resolver.get(uid).await?; - let meta = UpdateMeta::DeleteDocuments { documents }; + let meta = UpdateMeta::DeleteDocuments { ids: documents }; let (_, receiver) = mpsc::channel(1); let status = self.update_handle.update(meta, receiver, uuid).await?; Ok(status) diff --git a/meilisearch-http/src/index_controller/update_actor/store/mod.rs b/meilisearch-http/src/index_controller/update_actor/store/mod.rs index fc5c44568..e7b719fc9 100644 --- a/meilisearch-http/src/index_controller/update_actor/store/mod.rs +++ b/meilisearch-http/src/index_controller/update_actor/store/mod.rs @@ -174,7 +174,7 @@ impl UpdateStore { Ok(Some(_)) => (), Ok(None) => break, Err(e) => { - error!("Fatal error while processing update that requires the update store to shutdown: {}", e); + error!("Fatal error while processing an update that requires the update store to shutdown: {}", e); must_exit.store(true, Ordering::SeqCst); break 'outer; } @@ -185,9 +185,9 @@ impl UpdateStore { } } } - }); - error!("Update store loop exited."); + error!("Update store loop exited."); + }); Ok(update_store) } diff --git a/meilisearch-http/src/index_controller/updates.rs b/meilisearch-http/src/index_controller/updates.rs index 86b33e3f2..ea2ffb80d 100644 --- a/meilisearch-http/src/index_controller/updates.rs +++ b/meilisearch-http/src/index_controller/updates.rs @@ -24,7 +24,7 @@ pub enum UpdateMeta { }, ClearDocuments, DeleteDocuments { - documents: Vec + ids: Vec }, Settings(Settings), }