-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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/parser: fix memory leak of scanned comments #127711
Conversation
It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR? 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
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.
Nice, find!
Reviewed all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @michae2)
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.
Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: complete! 2 of 0 LGTMs obtained (waiting on @mgartner and @michae2)
-- commits
line 14 at r1:
nit: should we add a release note for it? It looks like this behavior has been present since forever22.2.
TFTRs! bors r+ |
bors r- |
Canceled. |
This commit fixes a memory leak that cause a session's `scanner.Scanner`, which is embedded in a `pgwire.conn` via a `parser.Parser`, to retain previously scanned SQL comments in all parsed SQL statements. The scanner's slice of comments would continue to grow as it parsed new SQL strings with comments, as long as the session remained open. Also, the slice of comments holds references to the bytes in `pgwire` read buffers, preventing those buffers from being GC'd. Fixes cockroachdb#127710 Release note (bug fix): A bug has been fixed that caused a memory leak when executing SQL statements with comments, for example, `SELECT /* comment */ 1;`. Memory owned by a SQL session would continue to grow as these types of statements were executed. The memory would only be released when closing the SQL session. This bug has been present since version 23.1.
0186c32
to
6ea14db
Compare
Done. Looks like it made it into 23.1, but the backport to 22.2 was not merged: #92844. |
bors r+ |
Build failed (retrying...): |
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.
Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: complete! 2 of 0 LGTMs obtained (and 1 stale) (waiting on @mgartner)
This commit fixes a memory leak that cause a session's
scanner.Scanner
, which is embedded in apgwire.conn
via aparser.Parser
, to retain previously scanned SQL comments in all parsedSQL statements. The scanner's slice of comments would continue to grow
as it parsed new SQL strings with comments, as long as the session
remained open. Also, the slice of comments holds references to the bytes
in
pgwire
read buffers, preventing those buffers from being GC'd.Fixes #127710
Release note (bug fix): A bug has been fixed that caused a memory leak
when executing SQL statements with comments, for example,
SELECT /* comment */ 1;
. Memory owned by a SQL session would continueto grow as these types of statements were executed. The memory would
only be released when closing the SQL session. This bug has been present
since version 23.1.