内容简介:Elasticsearch partial update内置了乐观锁并发控制机制。同样是基于_version(新版本更新为if_seq_no和if_primary_term)进行乐观锁的并发控制。详细请看:这里多提一点就是使用partial update有一个参数叫retry_on_conflict,也就是可以基于retry策略:我们回顾一下之前说的乐观锁并发控制策略
Elasticsearch partial update内置了乐观锁并发控制机制。同样是基于_version(新版本更新为if_seq_no和if_primary_term)进行乐观锁的并发控制。详细请看: https://segmentfault.com/a/11...
这里多提一点就是使用partial update有一个参数叫retry_on_conflict,也就是可以基于retry策略:
我们回顾一下之前说的乐观锁并发控制策略
在高并发更新数据时,它基于最新的数据和if_seq_no,if_primary_term进行修改,可能这个过程会需要反复执行好几次,才能成功,特别是在多线程并发更新同一条数据很频繁的情况下。
而partial update就是再次基础上添加了一个参数retry_on_conflict,可以设置最多重复的次数。
示例:
POST /test_index/_update/3?retry_on_conflict=5
{
"doc": {
"test_field1": "update test1"
}
}
GET /test_index/_doc/3
{
"_index" : "test_index",
"_type" : "_doc",
"_id" : "3",
"_version" : 3,
"_seq_no" : 2,
"_primary_term" : 1,
"found" : true,
"_source" : {
"test_field1" : "update test1",
"test_field2" : "update test2"
}
}
以上所述就是小编给大家介绍的《elasticsearch学习笔记(十五)——Elasticsearch partial update内置乐观锁并发控制》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Masterminds of Programming
Federico Biancuzzi、Chromatic / O'Reilly Media / 2009-03-27 / USD 39.99
Description Masterminds of Programming features exclusive interviews with the creators of several historic and highly influential programming languages. Think along with Adin D. Falkoff (APL), Jame......一起来看看 《Masterminds of Programming》 这本书的介绍吧!