Bug #45992 innodb memory not freed after shutdown
Submitted: 7 Jul 2009 8:15 Modified: 20 Jun 2010 0:39
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:5.4.2-debug OS:Linux (32-bit fc8)
Assigned to: Satya B
Tags: Leak, memory leak, regression
Triage: Triaged: D2 (Serious)

[7 Jul 2009 8:15] Shane Bester
Description:
innodb doesn't free all memory before shutting down:

5.4.2 output from valgrind:

==7100== 33,008 bytes in 3 blocks are definitely lost in loss record 7 of 8
==7100==    at 0x4005400: malloc (vg_replace_malloc.c:149)
==7100==    by 0x84B9A74: mem_area_alloc (mem0pool.c:334)
==7100==    by 0x84B8E0A: mem_heap_create_block (mem0mem.c:362)
==7100==    by 0x84B8348: mem_heap_create_func (mem0mem.ic:421)
==7100==    by 0x84B848E: mem_alloc_func (mem0mem.ic:511)
==7100==    by 0x84EA35F: thr_local_create (thr0loc.c:166)
==7100==    by 0x84EA22D: thr_local_get (thr0loc.c:78)
==7100==    by 0x84EA317: thr_local_get_in_ibuf_field (thr0loc.c:146)
==7100==    by 0x84A4637: ibuf_enter (ibuf0ibuf.c:251)
==7100==    by 0x84A49FD: ibuf_data_init_for_space (ibuf0ibuf.c:487)
==7100==    by 0x84972C8: fil_ibuf_init_at_db_start (fil0fil.c:1488)
==7100==    by 0x84A485B: ibuf_init_at_db_start (ibuf0ibuf.c:402)
==7100== 
==7100== 
==7100== 4,249,232 bytes in 114 blocks are still reachable in loss record 8 of 8
==7100==    at 0x4005400: malloc (vg_replace_malloc.c:149)
==7100==    by 0x84B9A74: mem_area_alloc (mem0pool.c:334)
==7100==    by 0x84B8E0A: mem_heap_create_block (mem0mem.c:362)
==7100==    by 0x84B8348: mem_heap_create_func (mem0mem.ic:421)
==7100==    by 0x84B848E: mem_alloc_func (mem0mem.ic:511)
==7100==    by 0x84F1043: trx_doublewrite_init (trx0sys.c:117)
==7100==    by 0x84F11B0: trx_sys_create_doublewrite_buf (trx0sys.c:196)
==7100==    by 0x84E73A5: innobase_start_or_create_for_mysql (srv0start.c:1643)
==7100==    by 0x846DA2D: innobase_init(void*) (ha_innodb.cc:1785)
==7100==    by 0x8389286: ha_initialize_handlerton (handler.cc:433)
==7100==    by 0x843E488: plugin_initialize(st_plugin_int*) (sql_plugin.cc:1003)
==7100==    by 0x843FB20: plugin_init(int*, char**, int) (sql_plugin.cc:1216)
==7100== 

==7100== LEAK SUMMARY:
==7100==    definitely lost: 33,008 bytes in 3 blocks.  <----- here
==7100==      possibly lost: 2,992 bytes in 22 blocks.
==7100==    still reachable: 4,250,136 bytes in 119 blocks.
==7100==         suppressed: 0 bytes in 0 blocks.

How to repeat:
valgrind --tool=memcheck --leak-check=full   -v --show-reachable=yes   ./bin/mysqld  --no-defaults   --skip-grant-tables --skip-name-resolve  --socket=sock.sock   --basedir=. --datadir=./data

then 'mysqladmin -uroot shutdown'
[7 Jul 2009 8:50] Shane Bester
cloned from parent branch: http://bazaar.launchpad.net/%7Emysql/mysql-server/mysql-5.4/

[sbester@box1 5.4]$ bzr revno
2854
[7 Jul 2009 13:35] Valerii Kravchuk
Thank you for the bug report. Verified just as described.
[13 Aug 2009 7:21] Marko Mäkelä
Is this repeatable with the InnoDB Plugin 1.0.4? For me, it is not. But I found this leak without --no-defaults, using my config:

==28098== 27 bytes in 1 blocks are definitely lost in loss record 3 of 9
==28098==    at 0x4023D6E: malloc (vg_replace_malloc.c:207)
==28098==    by 0x8474FF2: ut_malloc_low (ut0mem.c:106)
==28098==    by 0x847528C: ut_malloc (ut0mem.c:244)
==28098==    by 0x845EA12: srv_add_path_separator_if_needed (srv0start.c:551)
==28098==    by 0x845EABB: open_or_create_log_file (srv0start.c:613)
==28098==    by 0x845FEC9: innobase_start_or_create_for_mysql (srv0start.c:1440)
==28098==    by 0x84028E5: _ZL13innobase_initPv (ha_innodb.cc:2221)
==28098==    by 0x833B4C3: ha_initialize_handlerton(st_plugin_int*) (handler.cc:432)
==28098==    by 0x83DD578: _ZL17plugin_initializeP13st_plugin_int (sql_plugin.cc:1014)
==28098==    by 0x83E0E65: plugin_init(int*, char**, int) (sql_plugin.cc:1238)
==28098==    by 0x820DB93: _ZL22init_server_componentsv (mysqld.cc:3883)
==28098==    by 0x820E5D9: main (mysqld.cc:4355)
[13 Sep 2009 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[14 Oct 2009 9:37] Ståle Deraas
Can you please provide information if it's repeatable in 5.5.0
Thank you.
[30 Nov 2009 11:32] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/92057

3221 Satya B	2009-11-30
      Applying InnoDB Plugin 1.0.6 snapshot,part 1. Fixes BUG#45992 and BUG#46656
      
      Detailed revision comments:
      
      r6130 | marko | 2009-11-02 11:42:56 +0200 (Mon, 02 Nov 2009) | 9 lines
      branches/zip: Free all resources at shutdown. Set pointers to NULL, so
      that Valgrind will not complain about freed data structures that are
      reachable via pointers.  This addresses Bug #45992 and Bug #46656.
      
      This patch is mostly based on changes copied from branches/embedded-1.0,
      mainly c5432, c3439, c3134, c2994, c2978, but also some other code was
      copied.  Some added cleanup code is specific to MySQL/InnoDB.
      
      rb://199 approved by Sunny Bains
[1 Dec 2009 10:08] Satya B
patch queued to 5.1-bugteam storage/innodb_plugin.

Will be merged 5.5.*(mysql-trunk).
[2 Dec 2009 8:05] Bugs System
Pushed into 5.1.42 (revid:joro@sun.com-20091202080033-mndu4sxwx19lz2zs) (version source revid:satya.bn@sun.com-20091130113205-qcewe64fh8191c52) (merge vers: 5.1.42) (pib:13)
[15 Dec 2009 3:06] Paul Dubois
Noted in 5.1.42 changelog.

Valgrind errors for InnoDB Plugin were corrected.

Setting report to NDI pending push to 5.5.x+.
[16 Dec 2009 8:38] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091216083311-xorsasf5kopjxshf) (version source revid:alik@sun.com-20091214191830-wznm8245ku8xo702) (merge vers: 6.0.14-alpha) (pib:14)
[16 Dec 2009 8:45] Bugs System
Pushed into 5.5.0-beta (revid:alik@sun.com-20091216082430-s0gtzibcgkv4pqul) (version source revid:satya.bn@sun.com-20091202140050-nh3ebk6s3bziv8cb) (merge vers: 5.5.0-beta) (pib:14)
[16 Dec 2009 8:52] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20091216083231-rp8ecpnvkkbhtb27) (version source revid:alik@sun.com-20091212203859-fx4rx5uab47wwuzd) (merge vers: 5.6.0-beta) (pib:14)
[16 Dec 2009 16:13] Paul Dubois
Noted in 5.5.1, 6.0.14 changelogs.
[12 Mar 2010 14:14] Bugs System
Pushed into 5.1.44-ndb-7.0.14 (revid:jonas@mysql.com-20100312135944-t0z8s1da2orvl66x) (version source revid:jonas@mysql.com-20100312115609-woou0te4a6s4ae9y) (merge vers: 5.1.44-ndb-7.0.14) (pib:16)
[12 Mar 2010 14:30] Bugs System
Pushed into 5.1.44-ndb-6.2.19 (revid:jonas@mysql.com-20100312134846-tuqhd9w3tv4xgl3d) (version source revid:jonas@mysql.com-20100312060623-mx6407w2vx76h3by) (merge vers: 5.1.44-ndb-6.2.19) (pib:16)
[12 Mar 2010 14:46] Bugs System
Pushed into 5.1.44-ndb-6.3.33 (revid:jonas@mysql.com-20100312135724-xcw8vw2lu3mijrhn) (version source revid:jonas@mysql.com-20100312103652-snkltsd197l7q2yg) (merge vers: 5.1.44-ndb-6.3.33) (pib:16)
[5 May 2010 15:12] Bugs System
Pushed into 5.1.47 (revid:joro@sun.com-20100505145753-ivlt4hclbrjy8eye) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[6 May 2010 17:45] Paul Dubois
Push resulted from incorporation of InnoDB tree. No changes pertinent to this bug.
Re-closing.
[28 May 2010 6:11] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100524190136-egaq7e8zgkwb9aqi) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (pib:16)
[28 May 2010 6:39] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100524190941-nuudpx60if25wsvx) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[28 May 2010 7:06] Bugs System
Pushed into 5.5.5-m3 (revid:alik@sun.com-20100524185725-c8k5q7v60i5nix3t) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[29 May 2010 22:52] Paul Dubois
Push resulted from incorporation of InnoDB tree. No changes pertinent to this bug.
Re-closing.
[15 Jun 2010 8:13] Bugs System
Pushed into 5.5.5-m3 (revid:alik@sun.com-20100615080459-smuswd9ooeywcxuc) (version source revid:mmakela@bk-internal.mysql.com-20100415070122-1nxji8ym4mao13ao) (merge vers: 5.1.47) (pib:16)
[15 Jun 2010 8:29] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100615080558-cw01bzdqr1bdmmec) (version source revid:mmakela@bk-internal.mysql.com-20100415070122-1nxji8ym4mao13ao) (pib:16)
[17 Jun 2010 12:16] Bugs System
Pushed into 5.1.47-ndb-7.0.16 (revid:martin.skold@mysql.com-20100617114014-bva0dy24yyd67697) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[17 Jun 2010 13:03] Bugs System
Pushed into 5.1.47-ndb-6.2.19 (revid:martin.skold@mysql.com-20100617115448-idrbic6gbki37h1c) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[17 Jun 2010 13:43] Bugs System
Pushed into 5.1.47-ndb-6.3.35 (revid:martin.skold@mysql.com-20100617114611-61aqbb52j752y116) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)