6: Partial Update internal principles and optimistic locking concurrency control

Partial Update internal execution process:
  1. First, ES document is immutable , they can only be modified, it can not be replaced. Update Api is no exception.
  2. Simple Update API previously described using the same retrieval - modification - Index Reconstruction (REINDEX) processing. The difference is that this process takes place within the slice.
  3. ES equivalent internal Shard been performed Get (This document is available for all data), CreateDoc (according to the request to generate a new document), Put (ES write the new document). If you use the full amount of the replacement, which will take place in three steps Java program, but if a partial update, ES will help us to do these things.
 
Partial Update of benefits:
  1. Converting the original three network requests is 1, reducing the network load
  2. The Java program logic easier
  3. Due to retrieve and re-indexing occurs within shard, both small step intervals, greatly reducing the potential for conflict
 
Concurrency issues:
    1. The smaller the interval to retrieve and rebuild indexes (reindex) step, the smaller the chance conflicting changes. But it does not completely eliminate the possibility of conflict. In the update still possible before trying to re-index, a request from another process to modify the document.
    2. Therefore, the internal reference Java ES also steps to achieve concurrency control based on optimistic locking version of.
    3. We can optimistic lock on the inside of the ES, set some parameters:
    After concurrency conflicts, allowing the number of retries: retry_on_conflict
POST /test_index/test_type/1/_update?retry_on_conflict=5
{
    "doc":{
        "num":20
    }
}
 

Guess you like

Origin www.cnblogs.com/cc299/p/11032809.html