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

CREATE INDEX leaks memory if running out of undo log space

Details

    • 10.3.6-1

    Description

      The test innodb.alter_crash fails due to a memory leak.
      The reduced test case is as follows:

      --source include/not_embedded.inc
      --source include/have_innodb.inc
      --source include/have_debug.inc
      CREATE TABLE t1(c1 INT) ENGINE=InnoDB;
      SET DEBUG_DBUG='+d,ib_create_table_fail_too_many_trx';
      --error ER_TOO_MANY_CONCURRENT_TRXS
      CREATE INDEX c1 ON t1 (c1);
      --source include/restart_mysqld.inc
      DROP TABLE t1;
      

      The leak occurs when row_merge_create_index_graph() returns an error to row_merge_create_index(). The injected error is triggered when a SYS_INDEXES record is about to be inserted for the created index.

      The error cannot be reproduced on MariaDB 10.0 or 10.1. A possible reason is that the code may have been refactored in WL#6501 TRUNCATE TABLE in MySQL 5.7.

      Attachments

        Issue Links

          Activity

            Memory leaks happens during addition of index in alter table.

            Three operations happens in row_merge_create_index in 10.2 or create_dict_index (10.3)

            (1) Insert the index entry in SYS_INDEXES system table.
            (2) Insert the field entry in SYS_FIELDS system table.
            (3) Create the b-tree for index and stores the root page number in SYS_INDEXES field.

            Between (2) and (3), InnoDB adds the index into table cache. It checks whether
            the index entry exceeds the half of the page. (dict_index_add_to_cache_w_vcol())

            If any error happens during (1) and (2) then InnoDB doesn't free the heap memory
            of an index. Luckily dict_index_add_to_cache_w_vcol() does free the heap memory
            of an index irrespective of results.

            thiru Thirunarayanan Balathandayuthapani added a comment - Memory leaks happens during addition of index in alter table. Three operations happens in row_merge_create_index in 10.2 or create_dict_index (10.3) (1) Insert the index entry in SYS_INDEXES system table. (2) Insert the field entry in SYS_FIELDS system table. (3) Create the b-tree for index and stores the root page number in SYS_INDEXES field. Between (2) and (3), InnoDB adds the index into table cache. It checks whether the index entry exceeds the half of the page. (dict_index_add_to_cache_w_vcol()) If any error happens during (1) and (2) then InnoDB doesn't free the heap memory of an index. Luckily dict_index_add_to_cache_w_vcol() does free the heap memory of an index irrespective of results.

            The memory leak is present also in MariaDB 10.0 and 10.1, possibly also 5.5. The test innodb.alter_crash was missing from 10.0 and 10.1. I ported it to 10.1 and plugged the memory leak in 10.1.39.

            marko Marko Mäkelä added a comment - The memory leak is present also in MariaDB 10.0 and 10.1, possibly also 5.5. The test innodb.alter_crash was missing from 10.0 and 10.1. I ported it to 10.1 and plugged the memory leak in 10.1.39.

            People

              marko Marko Mäkelä
              marko Marko Mäkelä
              Votes:
              0 Vote for this issue
              Watchers:
              5 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.