Do not commit transaction on failed updates

This commit is contained in:
Kerollmops 2021-09-30 11:08:41 +02:00 committed by Tamo
parent ed783b67ca
commit 6a691db7f8
No known key found for this signature in database
GPG Key ID: 20CD8020AFA88D69
2 changed files with 3 additions and 3 deletions

View File

@ -202,7 +202,9 @@ impl Index {
Ok(UpdateResult::DocumentDeletion { deleted }) Ok(UpdateResult::DocumentDeletion { deleted })
} }
}; };
txn.commit()?; if result.is_ok() {
txn.commit()?;
}
result result
})(); })();

View File

@ -276,8 +276,6 @@ impl IndexController {
let index = self.index_resolver.create_index(name, None).await?; let index = self.index_resolver.create_index(name, None).await?;
let update_result = let update_result =
UpdateMsg::update(&self.update_sender, index.uuid, update).await?; 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) Ok(update_result)
} else { } else {
Err(IndexResolverError::UnexistingIndex(name).into()) Err(IndexResolverError::UnexistingIndex(name).into())