Optimistic concurrency , refresh and flush


#1

How does optimistic concurrency behave before a refresh or flush is performed? In other words does a successful update with a given version number also guarantees that no other concurrent client can be successful using the same version number, that is before the data is actually pushed to a memory segment (every 1 sec by default from what I saw in the doc). I could not find something definitive in the documentation.


(Adrien Grand) #2

Hi Alain,

The reason it works is that elasticsearch also has a transaction log.

Elasticsearch maintains a set of locks that it uses for versioning, and for all index operations elasticsearch picks one of these locks based on the hash of your document ID. All the indexing of a document on a shard is performed under this lock.

Elasticsearch first locks the lock. Then it checks the current version of the document in the transaction log. If it can't be found, it looks up the version in the index. Then it verifies that the version number of the update is consistent with the current version of the document, if yes the document is indexed otherwise an error is raised. And finally Elasticsearch releases the lock.


(system) #3