Skip to content

Commit

Permalink
mvcc: revert change made by 10526
Browse files Browse the repository at this point in the history
Revert #10526 and its followup #10699.
  • Loading branch information
jingyih committed May 30, 2019
1 parent a7568d6 commit 4345f74
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions mvcc/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,10 @@ 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.Lock()
clone := ti.tree.Clone()
ti.Unlock()
ti.RLock()
defer ti.RUnlock()

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

3 comments on commit 4345f74

@suyashkumar2409
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello!
I wanted to know why this change was reverted. Is the clone operation heavy? How did you decide between greater concurrency and avoiding cloning?

@jingyih
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@suyashkumar2409 Please refer to #10772.

@suyashkumar2409
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand, clone is being done lazily, so you anyway need the read lock while traversing it later. Thanks for providing the reference.

Please sign in to comment.