Skip to content
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

planner: session memory usage cannot be released after disconnecting #49190

Closed
qw4990 opened this issue Dec 5, 2023 · 0 comments · Fixed by #49193
Closed

planner: session memory usage cannot be released after disconnecting #49190

qw4990 opened this issue Dec 5, 2023 · 0 comments · Fixed by #49193
Assignees
Labels
severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@qw4990
Copy link
Contributor

qw4990 commented Dec 5, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create a new session and run the code snippet below:

	mustExec(c.ExecContext(context.Background(), "set @@tidb_opt_fix_control='44823:0'"))
	mustExec(c.ExecContext(context.Background(), "create table if not exists t1 (a0 int, a1 int, a2 int, a3 int, a4 int)"))

	for i := 1; i <= 1000; i++ {
		tmp := "(?,?,?,?,?)"
		values := strings.Repeat(tmp+",", i-1) + tmp
		st, err := c.PrepareContext(context.Background(), "insert into t1 values "+values)
		must(err)

		var vals []any
		for k := 0; k < i*5; k++ {
			vals = append(vals, 1)
		}
		_, err = st.ExecContext(context.Background(), vals...)
		must(err)
	}

Then disconnect this session, trigger GO GC, take a look at the memory usage, and find the session's memory is not released:
image

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

3. What did you see instead (Required)

4. What is your TiDB version? (Required)

TiDB after #48152

5. Analysis

It seems like this PR put every connection handle into a global list, which makes the GO GC cannot release these connections:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants