# ES concurrent update question

**URL:** <https://discuss.elastic.co/t/es-concurrent-update-question/54136>\
**Category:** Elasticsearch\
**Created:** [June 28, 2016, 9:33am UTC](https://discuss.elastic.co/t/es-concurrent-update-question/54136 "2016-06-28T09:33:01Z")\
**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:** [June 28, 2016, 9:33am UTC](https://discuss.elastic.co/t/es-concurrent-update-question/54136/1 "2016-06-28T09:33:01Z")

</div>

1. let's assume concurrent update operation is A, B
2. let's assume each shard has one replica, then P and R stands for primary and R stands for replica
3. let's assume update operation without specifying version and therefore use internal versiont type

so it could happen different things:

1. P execute A, B, R execute A, B
2. P execute A, B, R execute B, A
3. P execute A, B, R execute only A, B has failed on R due to version conflict
4. P execute only A and B failed due to version conflit. R execute A

all of the above has the possibility to happen, right?

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [June 28, 2016, 10:13am UTC](https://discuss.elastic.co/t/es-concurrent-update-question/54136/2 "2016-06-28T10:13:14Z")

</div>

It all depends on the primary, not the replica(s).

If A arrives to the primary before B then change A will get (eg) version 2, and change B will get version 3. Theses changes are sent to the replica as the whole document, not just the update command.

If version 2 arrives before version, then they are both applied in order. If version 3 arrives before version 2 then version 3 is applied, and version 2 is silently rejected (because it is older than version 3).

Either way, the replica stays in sync with the primary.

---

<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:** [June 28, 2016, 10:23am UTC](https://discuss.elastic.co/t/es-concurrent-update-question/54136/3 "2016-06-28T10:23:40Z")

</div>

get it. 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:** [July 5, 2017, 10:39pm UTC](https://discuss.elastic.co/t/es-concurrent-update-question/54136/4 "2017-07-05T22:39:57Z")

</div>


