From 6a691db7f8870dbecb10198e2ddd57c2ff18fd6a Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Thu, 30 Sep 2021 11:08:41 +0200 Subject: [PATCH] Do not commit transaction on failed updates --- meilisearch-lib/src/index/updates.rs | 4 +++- meilisearch-lib/src/index_controller/mod.rs | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/meilisearch-lib/src/index/updates.rs b/meilisearch-lib/src/index/updates.rs index 0ae0aefdb..92d1bdcfe 100644 --- a/meilisearch-lib/src/index/updates.rs +++ b/meilisearch-lib/src/index/updates.rs @@ -202,7 +202,9 @@ impl Index { Ok(UpdateResult::DocumentDeletion { deleted }) } }; - txn.commit()?; + if result.is_ok() { + txn.commit()?; + } result })(); diff --git a/meilisearch-lib/src/index_controller/mod.rs b/meilisearch-lib/src/index_controller/mod.rs index 3ca1d3f3f..050767c0f 100644 --- a/meilisearch-lib/src/index_controller/mod.rs +++ b/meilisearch-lib/src/index_controller/mod.rs @@ -276,8 +276,6 @@ impl IndexController { let index = self.index_resolver.create_index(name, None).await?; let update_result = UpdateMsg::update(&self.update_sender, index.uuid, update).await?; - // ignore if index creation fails now, since it may already have been created - Ok(update_result) } else { Err(IndexResolverError::UnexistingIndex(name).into())