elasticsearch学习笔记(十五)——Elasticsearch partial update内置乐观锁并发控制
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"
}
} 相关推荐
84296033 2020-09-15
heimu 2020-08-02
herohope 2020-07-18
mrandy 2020-07-04
Jaystrong 2020-06-27
89921334 2020-06-26
debugjoker 2020-06-17
Linkaibin 2020-06-14
fanhuasijin 2020-06-14
Laxcus大数据技术 2020-06-13
hanshangzhi 2020-06-10
rainchxy 2020-06-07
Jerry 2020-06-01
lilygg 2020-05-29
lclcsmart 2020-05-27