Details
-
Bug
-
Status: Open (View Workflow)
-
Critical
-
Resolution: Unresolved
-
N/A
-
Can result in unexpected behaviour
Description
During testing of MDEV-35915 a memory leak was detected with LSAN. This memory leak occurs somewhat regularly during the current feature test, whereas it was not observed earlier. There could be some reasons for this (stressing [global] temporary tables), or it could be that MDEV-35915 introduced or worsened the leak. The leak is in old code (note # comment/code location)
sql/log_event_server.cc around line 1561 |
static start_alter_info *get_new_start_alter_info(THD *thd)
|
{
|
/*
|
Why on global memory ?- So that process_commit/rollback_alter should not get
|
error when spawned threads exits too early.
|
*/
|
start_alter_info *info;
|
if (!(info= (start_alter_info *)my_malloc(PSI_INSTRUMENT_ME, # <<<<< Memory leak upon my_alloc here
|
sizeof(start_alter_info), MYF(MY_WME))))
|
{
|
sql_print_error("Failed to allocate memory for ddl log free list");
|
return 0;
|
}
|
This code was introduced in Jan 2022 as part of MDEV-11675.
While the issue appears somewhat regularly during testing, it is not reproducible/reducable in spite of many attempts.
Here are thee LSAN traces of the issue:
MDEV-35915-6 CS 12.2.0 ed3c63488a1613377d92ee3ade3fe6870e39b4db (Optimized, Replica, UBASAN, Clang 21.1.0-20250811) Build 24/09/2025 |
2025-09-24 16:58:14 0 [Note] /test/MDEV-35915_6_UBASAN_MD240925-mariadb-12.2.0-linux-x86_64-opt/bin/mariadbd: Shutdown complete
|
Warning: Internal memory accounting error of 104 bytes
|
|
=================================================================
|
==2951537==ERROR: LeakSanitizer: detected memory leaks
|
|
Direct leak of 104 byte(s) in 1 object(s) allocated from:
|
#0 0x6209cb6e8b08 in malloc (/test/MDEV-35915_6_UBASAN_MD240925-mariadb-12.2.0-linux-x86_64-opt/bin/mariadbd+0x2fcdb08) (BuildId: 4bfbf791ce5d52e12fa19b8ce4aeef87e4172058)
|
#1 0x6209ce697ce5 in my_malloc /test/bb-12.2-nikita-global-tmp_opt_san/mysys/my_malloc.c:93:29
|
#2 0x6209cbc97c2c in get_new_start_alter_info(THD*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/log_event_server.cc:1561:35
|
#3 0x6209cbc97c2c in Query_log_event::handle_split_alter_query_log_event(rpl_group_info*, bool&) /test/bb-12.2-nikita-global-tmp_opt_san/sql/log_event_server.cc:1619:21
|
#4 0x6209cbc936da in Query_log_event::do_apply_event(rpl_group_info*, char const*, unsigned int) /test/bb-12.2-nikita-global-tmp_opt_san/sql/log_event_server.cc:2062:20
|
#5 0x6209cbd13ba8 in Log_event::apply_event(rpl_group_info*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/log_event.cc:3984:8
|
#6 0x6209cc072e5c in apply_event_and_update_pos_apply(Log_event*, THD*, rpl_group_info*, int) /test/bb-12.2-nikita-global-tmp_opt_san/sql/slave.cc:3615:19
|
#7 0x6209cc073d3d in apply_event_and_update_pos_for_parallel(Log_event*, THD*, rpl_group_info*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/slave.cc:3822:9
|
#8 0x6209cd216440 in rpt_handle_event(rpl_parallel_thread::queued_event*, rpl_parallel_thread*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/rpl_parallel.cc:66:8
|
#9 0x6209cd20adfc in handle_rpl_parallel_thread /test/bb-12.2-nikita-global-tmp_opt_san/sql/rpl_parallel.cc:1597:18
|
#10 0x6209cb6e638a in asan_thread_start(void*) crtstuff.c
|
|
SUMMARY: AddressSanitizer: 104 byte(s) leaked in 1 allocation(s).
|
MDEV-35915-6 CS 12.2.0 ed3c63488a1613377d92ee3ade3fe6870e39b4db (Optimized, Replica, UBASAN, Clang 21.1.0-20250811) Build 24/09/2025 |
2025-09-25 13:26:16 0 [Note] /test/MDEV-35915_6_UBASAN_MD240925-mariadb-12.2.0-linux-x86_64-opt/bin/mariadbd: Shutdown complete
|
Warning: Internal memory accounting error of 104 bytes
|
|
=================================================================
|
==67261==ERROR: LeakSanitizer: detected memory leaks
|
|
Direct leak of 104 byte(s) in 1 object(s) allocated from:
|
#0 0x58fe6a783b08 in malloc (/test/MDEV-35915_6_UBASAN_MD240925-mariadb-12.2.0-linux-x86_64-opt/bin/mariadbd+0x2fcdb08) (BuildId: 4bfbf791ce5d52e12fa19b8ce4aeef87e4172058)
|
#1 0x58fe6d732ce5 in my_malloc /test/bb-12.2-nikita-global-tmp_opt_san/mysys/my_malloc.c:93:29
|
#2 0x58fe6ad32c2c in get_new_start_alter_info(THD*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/log_event_server.cc:1561:35
|
#3 0x58fe6ad32c2c in Query_log_event::handle_split_alter_query_log_event(rpl_group_info*, bool&) /test/bb-12.2-nikita-global-tmp_opt_san/sql/log_event_server.cc:1619:21
|
#4 0x58fe6ad2e6da in Query_log_event::do_apply_event(rpl_group_info*, char const*, unsigned int) /test/bb-12.2-nikita-global-tmp_opt_san/sql/log_event_server.cc:2062:20
|
#5 0x58fe6adaeba8 in Log_event::apply_event(rpl_group_info*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/log_event.cc:3984:8
|
#6 0x58fe6b10de5c in apply_event_and_update_pos_apply(Log_event*, THD*, rpl_group_info*, int) /test/bb-12.2-nikita-global-tmp_opt_san/sql/slave.cc:3615:19
|
#7 0x58fe6b10ed3d in apply_event_and_update_pos_for_parallel(Log_event*, THD*, rpl_group_info*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/slave.cc:3822:9
|
#8 0x58fe6c2b1440 in rpt_handle_event(rpl_parallel_thread::queued_event*, rpl_parallel_thread*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/rpl_parallel.cc:66:8
|
#9 0x58fe6c2a5dfc in handle_rpl_parallel_thread /test/bb-12.2-nikita-global-tmp_opt_san/sql/rpl_parallel.cc:1597:18
|
#10 0x58fe6a78138a in asan_thread_start(void*) crtstuff.c
|
|
SUMMARY: AddressSanitizer: 104 byte(s) leaked in 1 allocation(s).
|
MDEV-35915-6 CS 12.2.0 ed3c63488a1613377d92ee3ade3fe6870e39b4db (Optimized, Replica, UBASAN, Clang 21.1.0-20250811) Build 24/09/2025 |
2025-09-25 23:53:03 0 [Note] /test/MDEV-35915_6_UBASAN_MD240925-mariadb-12.2.0-linux-x86_64-opt/bin/mariadbd: Shutdown complete
|
Warning: Internal memory accounting error of 104 bytes
|
|
=================================================================
|
==1306877==ERROR: LeakSanitizer: detected memory leaks
|
|
Direct leak of 104 byte(s) in 1 object(s) allocated from:
|
#0 0x573b2518db08 in malloc (/test/MDEV-35915_6_UBASAN_MD240925-mariadb-12.2.0-linux-x86_64-opt/bin/mariadbd+0x2fcdb08) (BuildId: 4bfbf791ce5d52e12fa19b8ce4aeef87e4172058)
|
#1 0x573b2813cce5 in my_malloc /test/bb-12.2-nikita-global-tmp_opt_san/mysys/my_malloc.c:93:29
|
#2 0x573b2573cc2c in get_new_start_alter_info(THD*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/log_event_server.cc:1561:35
|
#3 0x573b2573cc2c in Query_log_event::handle_split_alter_query_log_event(rpl_group_info*, bool&) /test/bb-12.2-nikita-global-tmp_opt_san/sql/log_event_server.cc:1619:21
|
#4 0x573b257386da in Query_log_event::do_apply_event(rpl_group_info*, char const*, unsigned int) /test/bb-12.2-nikita-global-tmp_opt_san/sql/log_event_server.cc:2062:20
|
#5 0x573b257b8ba8 in Log_event::apply_event(rpl_group_info*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/log_event.cc:3984:8
|
#6 0x573b25b17e5c in apply_event_and_update_pos_apply(Log_event*, THD*, rpl_group_info*, int) /test/bb-12.2-nikita-global-tmp_opt_san/sql/slave.cc:3615:19
|
#7 0x573b25b18d3d in apply_event_and_update_pos_for_parallel(Log_event*, THD*, rpl_group_info*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/slave.cc:3822:9
|
#8 0x573b26cbb440 in rpt_handle_event(rpl_parallel_thread::queued_event*, rpl_parallel_thread*) /test/bb-12.2-nikita-global-tmp_opt_san/sql/rpl_parallel.cc:66:8
|
#9 0x573b26cafdfc in handle_rpl_parallel_thread /test/bb-12.2-nikita-global-tmp_opt_san/sql/rpl_parallel.cc:1597:18
|
#10 0x573b2518b38a in asan_thread_start(void*) crtstuff.c
|
|
SUMMARY: AddressSanitizer: 104 byte(s) leaked in 1 allocation(s).
|
As we can see the memory loss is stable accross occurences - 104 bytes, and each time the issue is detected after shutdown. Please note the issue happens on the replica in a standard m/s setup.
nikitamalyavin Please check if there is a possibility this is feature related. If not, please re-assign to Elkin. Thank you
Attachments
Issue Links
- relates to
-
MDEV-11675 Lag Free Alter On Slave
-
- Closed
-
-
MDEV-35915 Implement Global temporary tables
-
- In Testing
-