# Updating two documents at once - error management

**URL:** <https://discuss.elastic.co/t/updating-two-documents-at-once-error-management/207223>\
**Category:** Elasticsearch\
**Created:** [November 9, 2019, 9:42pm UTC](https://discuss.elastic.co/t/updating-two-documents-at-once-error-management/207223 "2019-11-09T21:42:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luigi\_Bardelli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luigi_bardelli/32/55691_2.png) [@Luigi\_Bardelli](https://discuss.elastic.co/u/Luigi_Bardelli)\
**Post date:** [November 9, 2019, 9:42pm UTC](https://discuss.elastic.co/t/updating-two-documents-at-once-error-management/207223/1 "2019-11-09T21:42:58Z")

</div>

Hi all,  
after reading the optimistic concurrency docs, I would like to understand which is the best way to handle the following scenario:

1. client fetches two "related" documents
2. client does its biz logic, changing both
3. client tries to update the documents: the first one is correctly updated on ES, the second one for some reason gives error and it is not updated
4. ES is left in an inconsistent state, i.e. the first doc is post-biz logic, the second one is pre-biz logic.

This is a "transaction"-like scenario, and ES does not support transactions. But.... how would you manage this? Which is the most robust way to manage such errors? (saving to a temporary index/temporary \_ids? adding a flag to mark incomplete docs? ...)

many thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 7, 2019, 9:43pm UTC](https://discuss.elastic.co/t/updating-two-documents-at-once-error-management/207223/2 "2019-12-07T21:43:04Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
