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

sql: don't clear the memory account of the prepared stmt #83615

Merged
merged 1 commit into from
Jul 6, 2022

Conversation

yuzefovich
Copy link
Member

Previously, we had a bug of clearing the memory account of the prepared
statements right after that prepared statement is created although we do
keep the struct around. I believe this bug was introduced long time ago,
and it could result in some memory not being accounted for. This is now
fixed.

Partially addresses: #72581.

Release note: None

Previously, we had a bug of clearing the memory account of the prepared
statements right after that prepared statement is created although we do
keep the struct around. I believe this bug was introduced long time ago,
and it could result in some memory not being accounted for. This is now
fixed.

Release note: None
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@yuzefovich
Copy link
Member Author

I rediscovered #72581 when looking at the support issue, and I think we should have this quick fix that is backported since it seems quite easy and relatively important.

@yuzefovich
Copy link
Member Author

I'm also quite lazy and would like to not do any of the follow-up actions described in #72581 (including adding the corresponding tests), hoping we can just agree that it's better to have this issue fixed quickly rather than waiting until someone has free cycles to address the issue proper. 🤞

Copy link
Contributor

@cucaroach cucaroach left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @mgartner and @yuzefovich)


pkg/sql/conn_executor_prepare.go line 158 at r1 (raw file):

	// NB: if we start caching the plan, we'll want to keep around the memory
	// account used for the plan, rather than clearing it.
	defer prepared.memAcc.Clear(ctx)

It seems like if we remove this we should have some basic test that the decRef/incRef stuff is working and we aren't leaking, no?

@yuzefovich
Copy link
Member Author

I think it's ok to not add any new tests since this commit will not break the ref counting if it wasn't broken before. In other words, this commit cannot introduce an accounting leak, but it can make already existing leak larger. I don't think I've seen any evidence of that leak existing in the first place, so it seems ok (and worth it) to merge this without any new tests.

@yuzefovich
Copy link
Member Author

Friendly ping @cucaroach @mgartner

@yuzefovich
Copy link
Member Author

TFTR!

bors r+

@craig
Copy link
Contributor

craig bot commented Jul 6, 2022

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Jul 6, 2022

Build succeeded:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants