# Version conflict coming without passing version es 5.6

**URL:** <https://discuss.elastic.co/t/version-conflict-coming-without-passing-version-es-5-6/132248>\
**Category:** Elasticsearch\
**Created:** [May 17, 2018, 4:06am UTC](https://discuss.elastic.co/t/version-conflict-coming-without-passing-version-es-5-6/132248 "2018-05-17T04:06:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dilip\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dilip_kumar/32/15459_2.png) [@Dilip\_Kumar](https://discuss.elastic.co/u/Dilip_Kumar)\
**Post date:** [May 17, 2018, 4:06am UTC](https://discuss.elastic.co/t/version-conflict-coming-without-passing-version-es-5-6/132248/1 "2018-05-17T04:06:54Z")

</div>

Hi  
I am using elasticsearch with two nodes with both as master (elasticsearch 5.6). when i am sending update query with php client then getting error ;  
message '{"error":{"root\_cause":[{"type":"version\_conflict\_engine\_exception","reason":"[mytype][123456\_789]: version conflict, current version [25] is different than the one provided .

my request to es engine i am not giving any version with update api:  
ELASTIC\_HOST=array("192.168.1.yyy:9200","192.168.1.xxx:9200");  
$hosts = $ELASTIC\_HOST;  
$res = Elasticsearch\ClientBuilder::create()-\>setHosts($hosts)-\>build();

$params = array();  
$params['index'] = $index;  
$params['type'] = $type;  
$document = array("doc"=\>array("val"=\>"1"));  
$json\_esData = json\_encode($document);  
$params['id'] = 123456\_789;  
$params['body'] = $json\_esData;  
$es\_response = $res-\>update($params);

Please guide me how can i avoid this error

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [May 17, 2018, 4:26pm UTC](https://discuss.elastic.co/t/version-conflict-coming-without-passing-version-es-5-6/132248/2 "2018-05-17T16:26:42Z")

</div>

Update requests internally use versions to make sure the update is semantically correct. What happened is that the Update API fetched the document, noted the version, applied the changes and tried to reindex it. After fetching but before reindexing the change, some other process updated the document and so the update failed.

You just need to retry the update, or specify `retry_on_conflict` to do it automatically.

---

<div class="post-metadata">

**Author:** ![Dilip\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dilip_kumar/32/15459_2.png) [@Dilip\_Kumar](https://discuss.elastic.co/u/Dilip_Kumar)\
**Post date:** [May 31, 2018, 5:44pm UTC](https://discuss.elastic.co/t/version-conflict-coming-without-passing-version-es-5-6/132248/3 "2018-05-31T17:44:35Z")

</div>

Thank you polyfractal, i need to add ['retry\_on\_conflict'] = 5 , is it ok  
but what will happen according to you one request will go for update internally with previous version (suppose going update for 62) but version 63 is available.. what will do retry\_on\_conflict..

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [June 4, 2018, 2:02pm UTC](https://discuss.elastic.co/t/version-conflict-coming-without-passing-version-es-5-6/132248/4 "2018-06-04T14:02:31Z")

</div>

The internal version is basically just a counter, so if an update tries to act on an old version (e.g. update for version 62, but current version is 63), the update will be rejected. And if you have `retry_on_conflict` enabled it will just fetch the new version number and try again.

That's why updates with `retry_on_conflict` must be idempotent...they have to be applicable in any order, because you can't guarantee what order they will be applied in. Incrementing a counter is idempotent... it doesn't matter if it happens before or after another update.

But changing a name may not be, because it may depend on the old value. In that case you should probably handle the conflict in your application.

---

<div class="post-metadata">

**Author:** ![Dilip\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dilip_kumar/32/15459_2.png) [@Dilip\_Kumar](https://discuss.elastic.co/u/Dilip_Kumar)\
**Post date:** [June 5, 2018, 10:55am UTC](https://discuss.elastic.co/t/version-conflict-coming-without-passing-version-es-5-6/132248/5 "2018-06-05T10:55:58Z")

</div>

> [@polyfractal](#):
>
> But changing a name may not be, because it may depend on the old value. In that case you should probably handle the conflict in your application.

Thank you for valuable suggestion, can we use this for bulk uppdate

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [June 5, 2018, 2:00pm UTC](https://discuss.elastic.co/t/version-conflict-coming-without-passing-version-es-5-6/132248/6 "2018-06-05T14:00:00Z")

</div>

Yep, version can be supplied in bulk updates too.

---

<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 3, 2018, 2:00pm UTC](https://discuss.elastic.co/t/version-conflict-coming-without-passing-version-es-5-6/132248/7 "2018-07-03T14:00:01Z")

</div>

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