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

MariaDB daemon leaks memory with specific query

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 5.5.47, 5.5.50, 10.0.26, 10.1.16
    • 5.5.52, 10.1.18, 10.0.28
    • Optimizer
    • None
    • CentOS 7, Gentoo

    Description

      For every thousand times the following query is run with the provided data dump, the MariaDB daemon leaks ~35M of memory:

      SELECT GROUP_CONCAT(`memleak_vtr2`.`language_id` SEPARATOR ',') AS `translation_resources`, `d`.`serialized_c` FROM `memleak_d2` AS `d` LEFT JOIN `memleak_vtr2` ON `d`.`voter_id` = `memleak_vtr2`.`voter_id` GROUP BY `d`.`voter_id` ORDER BY RAND()

      If the query keeps getting run, the MariaDB daemon will continue leaking memory until the entire system runs out, well beyond what should be possible through the configured memory limits for MariaDB. The provided query is as close to a minimal case as I can get, but it is reproducible 100% of the time. In particular, I have verified that all of the following must be true for the memory leak to occur:

      • the GROUP_CONCAT must be present
      • serialized_c must be selected and must be large (multiple kilobytes per row - the original table had COMPRESS()ed data, the provided one is COMPRESS()ed random data of similar length)
      • memleak_vtr2 must be an InnoDB table (not MyISAM)
      • the GROUP BY must be present
      • the ORDER BY must be present
      • the ORDER BY must be by RAND()

      The amount of memory leaked appears to be proportional to the amount of data in the tables. It is worth noting that there is not a visible change in the MariaDB daemon's memory usage after every individual query execution, it takes multiple queries for that to happen. However, as mentioned before, over a larger number of queries (thousands), the amount of memory leaked is pretty consistent.

      Please see the attached data dump and minimal test case for reproduction. Verified on the following MariaDB versions:

      5.5.47-1.el7_2 (CentOS 7)
      5.5.50-1.el7_2 (CentOS 7)
      10.0.26 (Gentoo)
      10.1.16 (Gentoo)

      Note: memleak.php will report the amount of leaked memory after each run (if any), but relies on assumptions that are probably only true on CentOS 7. Simply check the memory usage manually on other platforms.

      Attachments

        1. memleak.dump
          192 kB
          Neil Skrypuch
        2. memleak.php
          0.8 kB
          Neil Skrypuch

        Activity

          People

            monty Michael Widenius
            neiltembo Neil Skrypuch
            Votes:
            0 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.