Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-17723

Memory leak in btr_defragment_calc_n_recs_for_size()

    XMLWordPrintable

Details

    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.

      Attachments

        Issue Links

          Activity

            People

              marko Marko Mäkelä
              marko Marko Mäkelä
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.