[MDEV-29977] Memory leak in rec_copy_prefix_to_buf / btr_blob_log_check_t::check Created: 2022-11-08  Updated: 2024-02-07  Resolved: 2022-11-15

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11
Fix Version/s: 10.10.2, 10.11.1, 10.3.38, 10.4.28, 10.5.19, 10.6.12, 10.7.8, 10.8.7, 10.9.5

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Thirunarayanan Balathandayuthapani
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-29600 Memory leak in row_log_table_apply_up... Closed

 Description   

The test case is non-deterministic. It fails every time for me, but try to --repeat --force-restart if it doesn't fail for you right away.

--source include/have_innodb.inc
--source include/have_sequence.inc
 
CREATE TABLE t (f longtext, KEY(f(1024))) ENGINE=InnoDB;
INSERT INTO t SELECT REPEAT('a',100000) FROM seq_1_to_500;
 
--connect (con1,localhost,root,,test)
--send
  ALTER TABLE t FORCE;
 
--connection default
UPDATE t SET f = NULL LIMIT 1;
UPDATE t SET f = REPEAT('b',1000000) LIMIT 1;
 
--connection con1
--reap
 
DROP TABLE t;
--disconnect con1

10.3 01ac7455

==2740416==ERROR: LeakSanitizer: detected memory leaks
 
Direct leak of 12 byte(s) in 1 object(s) allocated from:
    #0 0x7fcf72597e8f in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x555e07787ea8 in rec_copy_prefix_to_buf(unsigned char const*, dict_index_t const*, unsigned long, unsigned char**, unsigned long*) /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/storage/innobase/rem/rem0rec.cc:2002
    #2 0x555e07a9bf07 in btr_pcur_store_position(btr_pcur_t*, mtr_t*) /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/storage/innobase/btr/btr0pcur.cc:200
    #3 0x555e07a90c78 in btr_blob_log_check_t::check() /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/storage/innobase/btr/btr0cur.cc:7171
    #4 0x555e07a899ae in btr_store_big_rec_extern_fields(btr_pcur_t*, unsigned short*, big_rec_t const*, mtr_t*, blob_op) /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/storage/innobase/btr/btr0cur.cc:7372
    #5 0x555e07861d80 in row_log_table_apply_update /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/storage/innobase/row/row0log.cc:2328
    #6 0x555e078647c7 in row_log_table_apply_op /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/storage/innobase/row/row0log.cc:2671
    #7 0x555e07868c05 in row_log_table_apply_ops /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/storage/innobase/row/row0log.cc:3041
    #8 0x555e07869a79 in row_log_table_apply(que_thr_t*, dict_table_t*, TABLE*, ut_stage_alter_t*, dict_table_t*) /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/storage/innobase/row/row0log.cc:3150
    #9 0x555e075a9758 in ha_innobase::inplace_alter_table(TABLE*, Alter_inplace_info*) /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/storage/innobase/handler/handler0alter.cc:7223
    #10 0x555e06a94373 in handler::ha_inplace_alter_table(TABLE*, Alter_inplace_info*) (/mnt8t/bld/10.3-nightly/bin/mysqld+0x12a7373)
    #11 0x555e06a77116 in mysql_inplace_alter_table /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_table.cc:7774
    #12 0x555e06a88631 in mysql_alter_table(THD*, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*, HA_CREATE_INFO*, TABLE_LIST*, Alter_info*, unsigned int, st_order*, bool) /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_table.cc:10159
    #13 0x555e06bf1905 in Sql_cmd_alter_table::execute(THD*) /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_alter.cc:512
    #14 0x555e0683d843 in mysql_execute_command(THD*) /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_parse.cc:6076
    #15 0x555e06849675 in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_parse.cc:7855
    #16 0x555e06820cc3 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_parse.cc:1852
    #17 0x555e0681d87b in do_command(THD*) /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_parse.cc:1398
    #18 0x555e06be11ef in do_handle_one_connection(CONNECT*) /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_connect.cc:1403
    #19 0x555e06be0aeb in handle_one_connection /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_connect.cc:1308
    #20 0x555e0818e244 in pfs_spawn_thread /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/storage/perfschema/pfs.cc:1869
    #21 0x7fcf71c91ea6 in start_thread nptl/pthread_create.c:477
 
SUMMARY: AddressSanitizer: 12 byte(s) leaked in 1 allocation(s).

Reproducible on all of 10.3-10.11 (and EOL-ed 10.2 too).



 Comments   
Comment by Thirunarayanan Balathandayuthapani [ 2022-11-10 ]

Patch is in bb-10.3-MDEV-29977

Comment by Marko Mäkelä [ 2022-11-10 ]

Another memory leak in the same function (applying an update during an online table rebuild) was fixed in MDEV-29600, but for a different code path.

Comment by Marko Mäkelä [ 2022-11-10 ]

OK to push after addressing my review comments.

Generated at Thu Feb 08 10:12:43 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.