Skip to content

Commit

Permalink
Merge pull request #10699 from jingyih/protect_tree_clone_with_write_…
Browse files Browse the repository at this point in the history
…lock

mvcc: protect tree clone with write lock
  • Loading branch information
xiang90 authored May 1, 2019
2 parents fc69368 + 88922b0 commit 8a86a60
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mvcc/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ func (ti *treeIndex) keyIndex(keyi *keyIndex) *keyIndex {
func (ti *treeIndex) visit(key, end []byte, f func(ki *keyIndex)) {
keyi, endi := &keyIndex{key: key}, &keyIndex{key: end}

ti.RLock()
ti.Lock()
clone := ti.tree.Clone()
ti.RUnlock()
ti.Unlock()

clone.AscendGreaterOrEqual(keyi, func(item btree.Item) bool {
if len(endi.key) > 0 && !item.Less(endi) {
Expand Down

0 comments on commit 8a86a60

Please sign in to comment.