-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
membuffer: fix memory leak in red-black tree #1483
Conversation
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
@cfzjywxk I test this PR (with RBT enabled) is ok to pass TiDB's CI, PTAL. |
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@you06
Do we have a benchmark test with tidb to verify the memory leak issue is resolved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REST LGTM
Co-authored-by: cfzjywxk <cfzjywxk@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
This test can reproduce the memory leak issue in TiDB side, will add it to TiDB. func TestInsertRollbackMemoryLeak(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t(a varchar(255) primary key)")
key1 := strings.Repeat("a", 255)
key2 := strings.Repeat("b", 255)
tk.MustExec(`set global tidb_mem_oom_action='cancel'`)
tk.MustExec("set session tidb_mem_quota_query=10240")
tk.MustExec("begin")
tk.MustExec("insert into t values(?)", key2)
for i := 0; i < 100; i++ {
err := tk.ExecToErr("insert into t values(?), (?)", key1, key2)
require.Error(t, err)
if strings.Contains(err.Error(), "Duplicate") {
continue
}
require.NoError(t, err)
}
tk.MustExec("commit")
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cfzjywxk, zyguan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
close #1375, ref pingcap/tidb#56837
The issue #1375 figures out that the RBT membuffer cannot reuse free nodes which causes a memory leak. This pr uses marking the node as deleted to replace the actual deletion.
Pros:
Cons: