Bug #45272 Memory leak when connecting and disconnecting from the proxy
Submitted: 2 Jun 2009 17:31 Modified: 17 Aug 2009 15:18
Reporter: Diego Medina Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Proxy: Core Severity:S1 (Critical)
Version:0.7.0 OS:Any
Assigned to: MC Brown CPU Architecture:Any

[2 Jun 2009 17:31] Diego Medina
Description:
If you make many connections through the proxy port (many as in 152,021). the proxy process will end up using a lot of memory (as in 500MB) and it will keep increasing as the number of new connections come in (and disconnects)

 

How to repeat:
1- Start the Proxy using this lua script
http://forge.mysql.com/tools/tool.php?id=198
and http://forge.mysql.com/tools/tool.php?id=197 for the admin plugin

2- Check the memory usage of the proxy process
3- Connect and disconnect about 200 times
4- Check the memory usage again
5- Repeat 2 and 3 a few times and you will notice the memory going up

See Valgrind output 

==16058== 427,752 (350,976 direct, 76,776 indirect) bytes in 2,742 blocks are definitely lost in loss record 50 of 50
==16058==    at 0x4A04B32: calloc (vg_replace_malloc.c:279)
==16058==    by 0x52CB97B: g_malloc0 (gmem.c:151)
==16058==    by 0x4D2655E: network_address_new (network-address.c:58)
==16058==    by 0x4D254F9: network_socket_new (network-socket.c:232)
==16058==    by 0x566E2F8: proxy_connect_server (proxy-plugin.c:1582)
==16058==    by 0x4D1C871: plugin_call (network-mysqld.c:696)
==16058==    by 0x4D1CB01: network_mysqld_con_handle (network-mysqld.c:822)
==16058==    by 0x4D1D769: network_mysqld_con_accept (network-mysqld.c:1467)
==16058==    by 0x4E34DAA: event_process_active (event.c:387)
==16058==    by 0x4E35046: event_base_loop (event.c:536)
==16058==    by 0x4E34DFA: event_base_dispatch (event.c:407)
==16058==    by 0x4C101D8: chassis_event_thread_loop (chassis-event-thread.c:259)
==16058== 
==16058== LEAK SUMMARY:
==16058==    definitely lost: 351,015 bytes in 2,743 blocks.
==16058==    indirectly lost: 76,776 bytes in 5,484 blocks.
==16058==      possibly lost: 0 bytes in 0 blocks.
==16058==    still reachable: 13,045 bytes in 188 blocks.
==16058==         suppressed: 0 bytes in 0 blocks.
==16058== Reachable blocks (those to which a pointer was found) are not shown.
==16058== To see them, rerun with: --show-reachable=yes
[2 Jun 2009 17:54] Jan Kneschke
In trunk it is fixed as:

revno: 673
committer: jan@mysql.com
branch nick: trunk
timestamp: Tue 2009-06-02 19:52:35 +0200
message:
  fixed mem-leak as socket->dst is already allocated in network_socket_new()
[2 Jun 2009 18:10] Jan Kneschke
------------------------------------------------------------
revno: 661
committer: jan@mysql.com
branch nick: 0.7
timestamp: Tue 2009-06-02 19:55:44 +0200
message:
  fixed mem-leak as socket->dst is already allocated in network_socket_new() (fixes #45272)
[5 Jun 2009 4:00] Diego Medina
Verified fixed on 0.7.1 r 661
Verified fixed on 0.8.0 r 640
[17 Aug 2009 15:18] MC Brown
A note has been added to the 0.7.1 changelog: 

Due to a memory leak, memory usage for each uniqute connection to the proxy would increase, leading to very high consumption.