From c08dcac1d4ce437a6296c4061b720d2c38a4bdfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Mon, 28 Oct 2019 17:55:24 +0100 Subject: [PATCH 1/2] Abort the update transaction before calling the update callback --- meilidb-core/src/database.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/meilidb-core/src/database.rs b/meilidb-core/src/database.rs index 9bd8348b3..45ddb56b7 100644 --- a/meilidb-core/src/database.rs +++ b/meilidb-core/src/database.rs @@ -35,10 +35,13 @@ fn update_awaiter(receiver: Receiver<()>, env: heed::Env, update_fn: Arc { - if status.result.is_ok() { - if let Err(e) = writer.commit() { - error!("update transaction failed: {}", e) + match status.result { + Ok(_) => { + if let Err(e) = writer.commit() { + error!("update transaction failed: {}", e) + } } + Err(_) => writer.abort(), } if let Some(ref callback) = *update_fn.load() { From a43b37dfc1b20d3b81d148b0ec4925425004e5c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Mon, 28 Oct 2019 17:58:22 +0100 Subject: [PATCH 2/2] Send channel notification when clearing documents --- meilidb-core/src/store/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/meilidb-core/src/store/mod.rs b/meilidb-core/src/store/mod.rs index db3051ddd..c384d62ce 100644 --- a/meilidb-core/src/store/mod.rs +++ b/meilidb-core/src/store/mod.rs @@ -167,6 +167,7 @@ impl Index { } pub fn clear_all(&self, writer: &mut heed::RwTxn) -> MResult { + let _ = self.updates_notifier.send(()); update::push_clear_all(writer, self.updates, self.updates_results) }