Is there a way to handle concurrent patch updates to same document in Elastic App Search?
Its been observed that when two concurrent update statements(patch calls) are sent to Elastic App Search, only changes in one of the API calls gets reflected, however both of them returns success response with no errors.
The concurrent update problem is something that can happen when multiple database sessions are permitted to update the same data at the same time which is why it's called the concurrent update problem. Whenever a database user connects to the database, a new session is created.
I think your issue might be one of misunderstanding - App Search does not have "patch" APIs, but full "update" APIs. When you specify a document with an ID that already exists in your engine, you overwrite that document in its entirety. So whichever request is serviced second will win out. You may need to evaluate your architecture, to try to keep two distinct processes/threads from attempting to write to the same ID with different data at the same time.
Well that is embarassing. TIL, thank you for pointing that out.
Let me start over .
When you send the concurrent patch updates, are you patching the same fields with different values? Or different sets of fields for the same ID, but only one of the patches is getting applied?
Hello @Sean_Story ,
The two patch calls contains different fields. However there are certain fields such as timestamp which is available in both calls but it has same value in both APIs. So, it looks like :
Request body 1-
I'm looking at the code now and I believe this is a real bug that will need a fix. The App Search Partial Update API looks like it retrieves the current document and reindexes it with the new changes overriding the existing values rather than using the underlying Elasticsearch Partial Update API: Update API | Elasticsearch Guide [8.0] | Elastic.
I will create an internal issue to track this. Unfortunately, I don't have a great workaround at the moment. My apologies.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.