# Is there any correlation between ttl and version conflicts?

**URL:** https://discuss.elastic.co/t/is-there-any-correlation-between-ttl-and-version-conflicts/20497
**Category:** Elasticsearch
**Created:** [October 30, 2014, 12:38pm UTC](https://discuss.elastic.co/t/is-there-any-correlation-between-ttl-and-version-conflicts/20497 "2014-10-30T12:38:33Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Sebastian](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@Sebastian](https://discuss.elastic.co/u/Sebastian)
#### Post date: [October 30, 2014, 12:38pm UTC](https://discuss.elastic.co/t/is-there-any-correlation-between-ttl-and-version-conflicts/20497/1 "2014-10-30T12:38:33Z")

</div>

Hi folks,

I'm using elasticsearch to store and analyse logs. Since I wanted old logs to be deleted automatically I added a ttl to my mapping. Now I sometimes get version conflict exceptions when my (PHP) application tries to update a timestamp in one of the fields. I'm trying to update the field using cURL and because of session locking it is impossible for a single user to generate more than one curl\_exec()-call at a time. Furthermore I do not provide version information explicidly in the update query. There are two elasticsearch servers handling the log index however all queries are handled by only one of them. The other one is just a standby. The exceptions were thrown only after setting a ttl so I was wondering if there might be any correlation? Can any of you shed some light on that matter?

Best regards, Sebastian

---

<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: [October 31, 2014, 8:41am UTC](https://discuss.elastic.co/t/is-there-any-correlation-between-ttl-and-version-conflicts/20497/2 "2014-10-31T08:41:54Z")

</div>

Hi Sebastien,

I believe this could indeed be related, eg.

1. The update API gets the current version of the document (V1)
2. Elasticsearch deletes the document because of its TTL, which increments  
the version of the document to V2 \> V1
3. Elasticsearch builds the updated document and adds it to the index: it  
expects the current version in the index to be V1 to succeed, yet it is now  
V2 because of the TTL and thus the update fails.

For your information, it is generally a better practice to evict old logs  
to have time-based indices (eg. one index per week) and to remove whole  
indices when they become too old. This would be lighter for elasticsearch  
as removing an old index is just about removing files on the filesystem  
while deleteing lots of documents can trigger heavy merges in order to  
reclaim the disk space.

On Thu, Oct 30, 2014 at 1:38 PM, Sebastian [sebastianappel@gmx.de](mailto:sebastianappel@gmx.de) wrote:

> Hi folks,
> 
> I'm using elasticsearch to store and analyse logs. Since I wanted old logs  
> to be deleted automatically I added a ttl to my mapping. Now I sometimes  
> get  
> version conflict exceptions when my (PHP) application tries to update a  
> timestamp in one of the fields. I'm trying to update the field using cURL  
> and because of session locking it is impossible for a single user to  
> generate more than one curl\_exec()-call at a time. Furthermore I do not  
> provide version information explicidly in the update query. There are two  
> elasticsearch servers handling the log index however all queries are  
> handled  
> by only one of them. The other one is just a standby. The exceptions were  
> thrown only after setting a ttl so I was wondering if there might be any  
> correlation? Can any of you shed some light on that matter?
> 
> Best regards, Sebastian
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Is-there-any-correlation-between-ttl-and-version-conflicts-tp4065542.html](http://elasticsearch-users.115913.n3.nabble.com/Is-there-any-correlation-between-ttl-and-version-conflicts-tp4065542.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/1414672713198-4065542.post%40n3.nabble.com](https://groups.google.com/d/msgid/elasticsearch/1414672713198-4065542.post%40n3.nabble.com)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7UByw7q1NjhF-E3PB4%3DJzRAx8VMZkh8mhmRvgRYGujqQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7UByw7q1NjhF-E3PB4%3DJzRAx8VMZkh8mhmRvgRYGujqQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:52am UTC](https://discuss.elastic.co/t/is-there-any-correlation-between-ttl-and-version-conflicts/20497/3 "2017-07-06T00:52:52Z")

</div>


