[MDEV-17723] Memory leak in btr_defragment_calc_n_recs_for_size() Created: 2018-11-15  Updated: 2021-04-13  Resolved: 2021-04-13

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB, Storage Engine - XtraDB
Affects Version/s: 10.1.1, 10.2.0, 10.3.0, 10.4.0
Fix Version/s: 10.2.38, 10.3.29, 10.4.19, 10.5.10

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 1
Labels: optimize_table

Issue Links:
Problem/Incident
is caused by MDEV-5834 Merge Kakao Defragmentation implement... Closed

 Description   

The function btr_defragment_calc_n_recs_for_size() that was added to MariaDB 10.1.1 as part of MDEV-5834 is leaking memory when a table contains enough many columns.

There is a call to rec_get_offsets() that may invoke mem_heap_create(), but there is no call to mem_heap_free(heap).

This should be reproducible with:

SET GLOBAL innodb_defragment = 1;
OPTIMIZE TABLE table_with_many_columns;

Simple fix: Add

if (UNIV_LIKELY_NULL(heap)) mem_heap_free(heap);

Better fix: Remove this kind of use of rec_get_offsets(), and implement a record field iterator that can be used for computing the size of a record. There is no need to compute any offsets except when some algorithm requires random access to the fields of an index record.



 Comments   
Comment by Marko Mäkelä [ 2021-04-13 ]

I think that I fixed this as part of MDEV-24620, but I did not explicitly test it.

Generated at Thu Feb 08 08:38:37 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.