pingcap / pingcap/tidb

btree.BTreeG.clone() maybe called concurrently

Open
#62,391 2 comments 0 reactions 0 assignees View on GitHub
component/ddl type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

In the comments of btree.BTree.Clone(), it is stated that btree.BTree.Clone() method cannot be called concurrently.

https://github.com/google/btree/blob/aeba20f7a1e1315badec4eca4fdc9f754f5f880a/btree_generic.go#L613

But I noticed that in the tidb code, using btree.BTree.clone() does not add a lock.
I am concerned that btree.BTree.Clone() may be called concurrently and result in some strange memory leaks.

https://github.com/pingcap/tidb/blob/3580f5196ef1c12d5d7b2b1c2bb11f8112c33b0f/pkg/infoschema/infoschema_v2.go#L91

### 1. Minimal reproduce step (Required)

### 2. What did you expect to see? (Required)

Clone should not be called concurrently

### 3. What did you see instead (Required)

code did not add a lock when using btree.BTree.Clone()。

### 4. What is your TiDB version? (Required)

master

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.