-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hitting AlreadyExpiredException from updating document that has valid _ttl #9956
Comments
Hi @coxchen The |
Thanks for your reply. Sorry for the confusion. I didn't update the _timestamp field (or log_time in my example), instead I did partial update to the log_count field with:
I just want to update fields other than the _timestamp filed and _ttl field, so I don't see why I hit the AlreadyExpiredException. |
@coxchen It means that the document has actually expired, but not yet been deleted. Expired docs are only removed every 60 seconds. |
Nope, it's not that case. The document I'd like to update still has valid _ttl (>> 0). I first found this issue in a production system I'm working on. In this case, I had a document with _ttl originally set to 7d, and I got the AlreadyExpiredException from updating that document on the 4th day after it been indexed in ES. At that time, the document still has its _ttl about 3 days left. I did some experiments, which you can read the details at https://medium.com/@coxchen/document-obsolescence-in-elasticsearch-c5973dd9e68d if you have time. |
Below is the result of my experiments, showing how _ttl of document changes over time. I have four documents indexed in ES
with the following index mapping
I also have script to update the log_count field to document 2 and 4 periodically.
Supposedly, the curves of the 4 document should overlap. But you can see the yellow curve (document 2) is outstanding. It doesn't look right to me. Can you help to explain? |
I trace the source code and found that, in TTLFieldMapper.java, the _timestamp in document source will be used to check expiration when updating a document. So the workaround for my issue is to always provide the original _ttl value when updating the document, even though I don't have the intention to update _ttl. You can check my article for details: https://medium.com/@coxchen/saving-document-half-life-in-es-89be764f21ca |
Hi @coxchen Thanks for digging! I've just tried my own (slightly different) test and see the
Index a document using tomorrow's date:
Repeat these two steps to see the
|
Interesting, the log_time is some time in the future, making the _ttl growing with UPDATE. |
I have hit this same issue when upgrading from 1.4.2 to 1.5.2. I'm using a mvel script to update attributes in the document (neither the _timestamp or _ttl). The issue appears to happen for some documents but not others. |
Closing in favour of #18280 |
Hi,
I hit the AlreadyExpiredException from updating document with valid _ttl, i.e. _ttl greater than 0.
Here is my index mapping (simplified), both _timestamp and _ttl are enabled, and _timestamp is provided with customized path:
I did some experiments as documented in this article and found that, if I have mappings like above (both _timestamp and _ttl are enabled, and _timestamp is provided with customized path), I'll hit the AlreadyExpiredException from updating document with valid _ttl. I have tried both 1.3.1 and 1.4.2, same behavior.
Is this a known issue? Or is there any design intent behind this?
Thank you for your help!
The text was updated successfully, but these errors were encountered: