Skip to content

Commit

Permalink
mvcc: protect tree clone with write lock
Browse files Browse the repository at this point in the history
  • Loading branch information
jingyih committed May 1, 2019
1 parent fc69368 commit 88922b0
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 88922b0

Please sign in to comment.