From 88922b0d08e6f972a64a7ee3b8dab16fa1e03516 Mon Sep 17 00:00:00 2001 From: Jingyi Hu Date: Wed, 1 May 2019 12:34:09 -0700 Subject: [PATCH] mvcc: protect tree clone with write lock --- mvcc/index.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mvcc/index.go b/mvcc/index.go index 8588977890c..e2964cf5bbf 100644 --- a/mvcc/index.go +++ b/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) {