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

LP:821241 - Server reports memory exhausted on statement prepare

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 10.0.2, 5.5.31, 5.1.67, 5.2.14, 5.3.12, 10.1, 10.0, 5.5
    • Fix Version/s: 10.1
    • Component/s: Parser

      Description

      Applying this trick: http://openquery.com/blog/cache-preloading-mysqld-startup
      (I realise this has been superceded by the XtraDB LRU dump/reload stuff - but since the below occurred and appears to identify a bug, it's useful to report anyway)

      It's MariaDB 5.2.7

      MariaDB [(none)]> SET SESSION group_concat_max_len=100*1024*1024;
      Query OK, 0 rows affected (0.00 sec)
      
      MariaDB [(none)]> SELECT GROUP_CONCAT(CONCAT('SELECT COUNT(`',column_name,'`) FROM `',table_schema,'`.`',table_name,'` FORCE INDEX (`',index_name,'`)') SEPARATOR ' UNION ALL ') INTO @sql FROM information_schema.statistics WHERE table_schema NOT IN ('information_schema','mysql') AND seq_in_index = 1;
      Query OK, 1 row affected (0.15 sec)
      
      MariaDB [(none)]> select length(@sql);
      +--------------+
      | length(@sql) |
      +--------------+
      |       869378 |
      +--------------+
      1 row in set (0.00 sec)
      

      so far so good, resulting SQL query is only 800K long.

      MariaDB [(none)]> PREPARE stmt FROM @sql;
      ERROR 1064 (42000): memory exhausted near 'INDEX (`PRIMARY`) UNION ALL SELECT COUNT(`id`) FROM `dbname`.`colname' at line 1
      

      It appears (thanks HarrisonF) that the parser runs out of memory? We reckon that'd be a bug.

      I'm happy to pass along the entire @sql string, but a) it contains customer details (db/table/col names) so it'd have to be in private and b) the SQL wouldn't run on any other server anyway since the parser would find nonexistent dbs/tables/cols and thus never get to the bug.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              ratzpo Rasmus Johansson added a comment -

              Launchpad bug id: 821241

              Show
              ratzpo Rasmus Johansson added a comment - Launchpad bug id: 821241
              Hide
              elenst Elena Stepanova added a comment - - edited
              1. Also reproducible on all of MySQL 5.1 - 5.7
              MTR test case
              
              --disable_warnings
              DROP DATABASE IF EXISTS db;
              --enable_warnings
              CREATE DATABASE db;
              USE db;
              
              --let $tables = 200
              while ($tables) 
              {
              	--let $sql = CREATE TABLE t$tables (pk INT NOT NULL
              	--let $indexes = PRIMARY KEY (pk)
              	--let $columns = 63
              	while ($columns) 
              	{
              		--let $sql = $sql, c$columns INT
              		--let $indexes = $indexes, INDEX ind$columns (c$columns)
              		--dec $columns
              	}
              	--let $sql = $sql, $indexes) ENGINE=MyISAM
              	--eval $sql
              	--dec $tables
              }
              
              SET SESSION group_concat_max_len=100*1024*1024;
              
              SELECT GROUP_CONCAT(CONCAT('SELECT COUNT(`',column_name,'`) FROM `',table_schema,'`.`',table_name,'` FORCE INDEX (`',index_name,'`)') SEPARATOR ' UNION ALL ') INTO @sql FROM information_schema.statistics WHERE table_schema NOT IN ('information_schema','mysql') AND seq_in_index = 1;
              
              select length(@sql);
              
              prepare stmt from @sql;
              
              DROP DATABASE db;
              
              Show
              elenst Elena Stepanova added a comment - - edited Also reproducible on all of MySQL 5.1 - 5.7 MTR test case --disable_warnings DROP DATABASE IF EXISTS db; --enable_warnings CREATE DATABASE db; USE db; --let $tables = 200 while ($tables) { --let $sql = CREATE TABLE t$tables (pk INT NOT NULL --let $indexes = PRIMARY KEY (pk) --let $columns = 63 while ($columns) { --let $sql = $sql, c$columns INT --let $indexes = $indexes, INDEX ind$columns (c$columns) --dec $columns } --let $sql = $sql, $indexes) ENGINE=MyISAM --eval $sql --dec $tables } SET SESSION group_concat_max_len=100*1024*1024; SELECT GROUP_CONCAT(CONCAT(' SELECT COUNT(`',column_name,'`) FROM `',table_schema,'`.`',table_name,'` FORCE INDEX (`',index_name,'`)') SEPARATOR ' UNION ALL ') INTO @sql FROM information_schema.statistics WHERE table_schema NOT IN ('information_schema','mysql') AND seq_in_index = 1; select length(@sql); prepare stmt from @sql; DROP DATABASE db;

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  arjenlentz Arjen Lentz
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated: