Memory leak when using per-query variables with subquery temp tables
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
Percona Server moved to https://jira.percona.com/projects/PS | Status tracked in 5.7 | |||||
5.5 |
Invalid
|
Undecided
|
Unassigned | |||
5.6 |
Fix Released
|
High
|
Laurynas Biveinis | |||
5.7 |
Fix Released
|
High
|
Laurynas Biveinis |
Bug Description
When per query variable feature is used to set max_statement_time Percona Server starts leaking memory for every statement.
-- Leak when using per-query-variable
USER PID RSS VSZ TIME COMMAND
mysql 53142 52383724 602199572 06:33:27 /usr/sbin/mysqld --basedir=/usr --datadir=
for (( i=0; i<10000; i++ )); do mysql -e "SET STATEMENT max_statement_
USER PID RSS VSZ TIME COMMAND
mysql 53142 55718656 602199572 06:33:40 /usr/sbin/mysqld --basedir=/usr --datadir=
diff in memory = 3MB
-- No leak when setting the same variable as session variable
The same query executed by setting SESSION variable:
USER PID RSS VSZ TIME COMMAND
mysql 53142 55722752 602199572 06:33:40 /usr/sbin/mysqld --basedir=/usr --datadir=
for (( i=0; i<10000; i++ )); do mysql -e "SET SESSION max_statement_
USER PID RSS VSZ TIME COMMAND
mysql 53142 55728912 602199572 06:33:52 /usr/sbin/mysqld --basedir=/usr --datadir=
diff in memory = 6KB
Before both the tests, MySQL was restarted.
I ran the same tests with Valgrind and that shows the leak more evidently.
valgrind --tool=massif --massif-
-- Valgrind (leaky)
USER PID RSS VSZ TIME COMMAND
mysql 34021 1968452 12701116 00:00:05 /usr/bin/
for (( i=0; i<10000; i++ )); do mysql -e "SET STATEMENT max_statement_
USER PID RSS VSZ TIME COMMAND
mysql 111410 16707852 27532328 00:06:05 /usr/bin/
-- Valgrind (non-leaky)
USER PID RSS VSZ TIME COMMAND
mysql 78481 1970676 12701116 00:00:04 /usr/bin/
for (( i=0; i<10000; i++ )); do mysql -e "SET SESSION max_statement_
USER PID RSS VSZ TIME COMMAND
mysql 78481 1998824 12733428 00:05:40 /usr/bin/
description: | updated |
summary: |
- Memory leak when using per-query variables to set MAX_STATEMENT_TIME + Memory leak when using per-query variables with subquery temp tables |
You can see in the the massif output that memory is never released and the memory usage just keeps increasing to 16GB.