-
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: memory leak of parsed SQL comments #127710
Labels
branch-release-23.1
Used to mark GA and release blockers, technical advisories, and bugs for 23.1
branch-release-23.2
Used to mark GA and release blockers, technical advisories, and bugs for 23.2
branch-release-24.1
Used to mark GA and release blockers, technical advisories, and bugs for 24.1
branch-release-24.2
Used to mark GA and release blockers, technical advisories, and bugs for 24.2
C-bug
Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Comments
mgartner
added
the
C-bug
Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
label
Jul 25, 2024
Hi @mgartner, please add branch-* labels to identify which branch(es) this C-bug affects. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
mgartner
added
branch-release-24.1
Used to mark GA and release blockers, technical advisories, and bugs for 24.1
branch-release-23.2
Used to mark GA and release blockers, technical advisories, and bugs for 23.2
branch-release-24.2
Used to mark GA and release blockers, technical advisories, and bugs for 24.2
labels
Jul 25, 2024
The best workaround is to regularly close and re-open connections, e.g., with a "max age" connection pool setting in the client. |
mgartner
added a commit
to mgartner/cockroach
that referenced
this issue
Jul 25, 2024
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: None
Some follow-up work: #127713 |
mgartner
added
the
branch-release-23.1
Used to mark GA and release blockers, technical advisories, and bugs for 23.1
label
Jul 26, 2024
craig bot
pushed a commit
that referenced
this issue
Jul 26, 2024
127711: sql/parser: fix memory leak of scanned comments r=mgartner a=mgartner 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 #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. Co-authored-by: Marcus Gartner <[email protected]>
blathers-crl bot
pushed a commit
that referenced
this issue
Jul 26, 2024
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 #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.
blathers-crl bot
pushed a commit
that referenced
this issue
Jul 26, 2024
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 #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.
blathers-crl bot
pushed a commit
that referenced
this issue
Jul 26, 2024
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 #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.
blathers-crl bot
pushed a commit
that referenced
this issue
Jul 26, 2024
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 #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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
branch-release-23.1
Used to mark GA and release blockers, technical advisories, and bugs for 23.1
branch-release-23.2
Used to mark GA and release blockers, technical advisories, and bugs for 23.2
branch-release-24.1
Used to mark GA and release blockers, technical advisories, and bugs for 24.1
branch-release-24.2
Used to mark GA and release blockers, technical advisories, and bugs for 24.2
C-bug
Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
We've discovered a memory leak in the parser that can retain memory for parsed SQL comments for as long as a session remains open.
Here's a reproduction that continually executes SQL statements that contain comments:
Running this against v23.2.7 we can observe that memory continues to climb past 1GB after a couple of minutes:
After applying a simply patch to remove the leak, memory plateaus just above 600MB:
Jira issue: CRDB-40562
The text was updated successfully, but these errors were encountered: