# Please help to confirm: even with upsert API, there could still happen data override

**URL:** <https://discuss.elastic.co/t/please-help-to-confirm-even-with-upsert-api-there-could-still-happen-data-override/38580>\
**Category:** Elasticsearch\
**Created:** [January 7, 2016, 8:44am UTC](https://discuss.elastic.co/t/please-help-to-confirm-even-with-upsert-api-there-could-still-happen-data-override/38580 "2016-01-07T08:44:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![makeyang](https://avatars.discourse-cdn.com/v4/letter/m/f05b48/32.png) [@makeyang](https://discuss.elastic.co/u/makeyang)\
**Post date:** [January 7, 2016, 8:44am UTC](https://discuss.elastic.co/t/please-help-to-confirm-even-with-upsert-api-there-could-still-happen-data-override/38580/1 "2016-01-07T08:44:20Z")

</div>

let's say we have 2 threads to upsert one document with same uid  
is it possible that both threads cound identify its a fresh newly doc and both execute insert operation, which will cause one thread override the other's data.

please help to verify if this could happen because I met some problem that only with the explaination could make sense whole things.

thanks.

---

<div class="post-metadata">

**Author:** ![makeyang](https://avatars.discourse-cdn.com/v4/letter/m/f05b48/32.png) [@makeyang](https://discuss.elastic.co/u/makeyang)\
**Post date:** [January 7, 2016, 9:35am UTC](https://discuss.elastic.co/t/please-help-to-confirm-even-with-upsert-api-there-could-still-happen-data-override/38580/2 "2016-01-07T09:35:36Z")

</div>

@jpountz  
@Christian_Dahlqvist  
can you guys help to share anything useful?

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [January 7, 2016, 9:42am UTC](https://discuss.elastic.co/t/please-help-to-confirm-even-with-upsert-api-there-could-still-happen-data-override/38580/3 "2016-01-07T09:42:04Z")

</div>

No this can't happen, you will get an error saying that there was a conflict in that case. You can tell elasticsearch to retry in that case with the `retry_on_conflict` parameter [https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html#\_parameters\_3](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html#_parameters_3)

---

<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:** [July 5, 2017, 11:26pm UTC](https://discuss.elastic.co/t/please-help-to-confirm-even-with-upsert-api-there-could-still-happen-data-override/38580/4 "2017-07-05T23:26:27Z")

</div>


