Browse Source

mvcc: protect tree clone with write lock

Jingyi Hu 6 years ago
parent
commit
88922b0d08
1 changed files with 2 additions and 2 deletions
  1. 2 2
      mvcc/index.go

+ 2 - 2
mvcc/index.go

@@ -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) {