mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
mvcc: release lock early when traversing index
Make a copy-on-write clone of index tree when traversing. So that lock can be released right after the clone to improve backend concurrency.
This commit is contained in:
parent
4b69cfc56b
commit
93732df3ef
@ -92,9 +92,10 @@ func (ti *treeIndex) visit(key, end []byte, f func(ki *keyIndex)) {
|
||||
keyi, endi := &keyIndex{key: key}, &keyIndex{key: end}
|
||||
|
||||
ti.RLock()
|
||||
defer ti.RUnlock()
|
||||
clone := ti.tree.Clone()
|
||||
ti.RUnlock()
|
||||
|
||||
ti.tree.AscendGreaterOrEqual(keyi, func(item btree.Item) bool {
|
||||
clone.AscendGreaterOrEqual(keyi, func(item btree.Item) bool {
|
||||
if len(endi.key) > 0 && !item.Less(endi) {
|
||||
return false
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user