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

Fix several memory leaks detected by valgrind #3204

Closed
5 tasks done
JavierJF opened this issue Dec 16, 2020 · 0 comments · Fixed by #3206
Closed
5 tasks done

Fix several memory leaks detected by valgrind #3204

JavierJF opened this issue Dec 16, 2020 · 0 comments · Fixed by #3206

Comments

@JavierJF
Copy link
Collaborator

JavierJF commented Dec 16, 2020

  • A clear description of the issue

During testing a couple of memory leaks have been detected in the valgrind output. The relevant valgrind output sections are:

  • Leak detected in Admin:
==226184== 525 (104 direct, 421 indirect) bytes in 1 blocks are definitely lost in loss record 2,144 of 2,440
==226184==    at 0x483ADEF: operator new(unsigned long) (vg_replace_malloc.c:342)
==226184==    by 0x3D6D06: SQLite3DB::execute_statement(char const*, char**, int*, int*, SQLite3_result**) (sqlite3db.cpp:254)
==226184==    by 0x3EC97F: MySQL_HostGroups_Manager::dump_table_mysql_galera_hostgroups() (MySQL_HostGroups_Manager.cpp:2200)
==226184==    by 0x4D6DBA: ProxySQL_Admin::save_mysql_servers_runtime_to_database(bool) (ProxySQL_Admin.cpp:9953)
==226184==    by 0x4DA484: ProxySQL_Admin::load_mysql_servers_to_runtime() (ProxySQL_Admin.cpp:10191)
==226184==    by 0x4CBCEF: ProxySQL_Admin::init_mysql_servers() (ProxySQL_Admin.cpp:8854)
==226184==    by 0x3A6843: ProxySQL_Main_init_phase3___start_all() (main.cpp:1337)
==226184==    by 0x3A813B: main (main.cpp:1786)
  • Leaks detected in libmariadbclient:
==226184== 19,200 (12,800 direct, 6,400 indirect) bytes in 100 blocks are definitely lost in loss record 2,407 of 2,440
==226184==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==226184==    by 0x8C0B80: mysql_init (mariadb_lib.c:1016)
==226184==    by 0x602068: MySQL_Connection::connect_start() (mysql_connection.cpp:659)
==226184==    by 0x603F69: MySQL_Connection::handler(short) (mysql_connection.cpp:937)
==226184==    by 0x45F0CA: MySQL_Session::handler___client_DSS_QUERY_SENT___server_DSS_NOT_INITIALIZED__get_connection() (MySQL_Session.cpp:5980)
==226184==    by 0x44BDA2: MySQL_Session::handler_again___status_CONNECTING_SERVER(int*) (MySQL_Session.cpp:2508)
==226184==    by 0x453C19: MySQL_Session::handler() (MySQL_Session.cpp:4242)
==226184==    by 0x42F87F: MySQL_Thread::process_all_sessions() (MySQL_Thread.cpp:4450)
==226184==    by 0x42E1E5: MySQL_Thread::run() (MySQL_Thread.cpp:4134)
==226184==    by 0x3A49ED: mysql_worker_thread_func(void*) (main.cpp:760)
==226184==    by 0x4A723E8: start_thread (in /usr/lib/libpthread-2.32.so)
==226184==    by 0x4EF5292: clone (in /usr/lib/libc-2.32.so)
==226184== 400 bytes in 100 blocks are definitely lost in loss record 2,089 of 2,440
==226184==    at 0x483CB65: calloc (vg_replace_malloc.c:760)
==226184==    by 0x8C0B4F: mysql_init (mariadb_lib.c:1014)
==226184==    by 0x602068: MySQL_Connection::connect_start() (mysql_connection.cpp:659)
==226184==    by 0x603F69: MySQL_Connection::handler(short) (mysql_connection.cpp:937)
==226184==    by 0x45F0CA: MySQL_Session::handler___client_DSS_QUERY_SENT___server_DSS_NOT_INITIALIZED__get_connection() (MySQL_Session.cpp:5980)
==226184==    by 0x44BDA2: MySQL_Session::handler_again___status_CONNECTING_SERVER(int*) (MySQL_Session.cpp:2508)
==226184==    by 0x453C19: MySQL_Session::handler() (MySQL_Session.cpp:4242)
==226184==    by 0x42F87F: MySQL_Thread::process_all_sessions() (MySQL_Thread.cpp:4450)
==226184==    by 0x42E1E5: MySQL_Thread::run() (MySQL_Thread.cpp:4134)
==226184==    by 0x3A49ED: mysql_worker_thread_func(void*) (main.cpp:760)
==226184==    by 0x4A723E8: start_thread (in /usr/lib/libpthread-2.32.so)
==226184==    by 0x4EF5292: clone (in /usr/lib/libc-2.32.so)

  • ProxySQL version

  • v2.0.16

All leaks are present in v2.0.16.

  • v2.1.0

'ProxySQL_Admin' leak is already fixed in this version, just the ones present in 'MySQL_Session', are present in v2.1.0.

  • OS version
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
  • The steps to reproduce the issue

Start ProxySQL, issue the following configuration to admin:

UPDATE global_variables SET variable_value='0' WHERE variable_name='mysql-free_connections_pct';
LOAD MYSQL VARIABLES TO RUNTIME;

then execute the following script:

for i in `seq 1 100` ; do
    mysql -h127.0.0.1 -usbtest1 -psbtest1 -P6033 -c -e '/* create_new_connection=1 */ SELECT 1' > /dev/null;
done
  • The full ProxySQL error log (default location: /var/lib/proxysql/proxysql.log)

The attached file contains the full ProxySQL error log and valgrind output containing the leaks:

proxysql_mem_leak.tar.gz

renecannao added a commit that referenced this issue Dec 20, 2020
Closes #3204: Fix several memory leaks detected by valgrind
renecannao added a commit that referenced this issue Dec 27, 2020
Closes #3204: Fix several memory leaks detected by valgrind
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 a pull request may close this issue.

1 participant