Comment 1 for bug 929603

Revision history for this message
Peter (Stig) Edwards (thatsafunnyname) wrote :

I have a reproducer for the "Out of memory" error being logged (not a crash), it is currently not trivial.
After increasing aria_pagecache_buffer_size from 128MB to 2048MB I no longer saw the "Out of memory" error in the error log, instead the mysql client returns "Using too big key for internal temp tables". Both errors go away when I remove the line:
  group_concat_max_len=131072
from the my.cnf file. Without the line the reported global default value of 1024 is being used. I also get the error using 65536, 32768, 16384, 8192, 4096 and 2048, only with 1024 does it run error free.

The queries with the errors are using GROUP_CONCAT.

"Out of memory" query:

UPDATE
  p_prelim_org AS pre
JOIN ( SELECT
         pre.encore_load,
         pre.cfterm_id,
         GROUP_CONCAT( CONCAT("[", fin_sec.label, "]") ORDER BY fin_sec.indent ASC SEPARATOR '' ) AS sub_label,
         MAX( fin_sec.indent ) AS sub_indent
       FROM
         p_prelim_org AS pre
         JOIN
         p_prelim_org AS sub_check
         ON pre.encore_load = sub_check.encore_load AND
            pre.cfterm_id_match = sub_check.cfterm_id AND
            pre.status = "MATCHED" AND
            pre.whos_structure = "FINAL" AND
            pre.indent_match + 1 < sub_check.indent AND
            pre.table_type = "CF"
         JOIN
         p_final_sections AS fin_sec
         ON pre.encore_load = fin_sec.encore_load AND
            pre.cfterm_id_match = fin_sec.cfterm_id AND
            pre.indent_match >= fin_sec.indent
            GROUP BY pre.encore_load, pre.cfterm_id
      ) AS sub_sec
        ON pre.encore_load = sub_sec.encore_load AND
           pre.cfterm_id = sub_sec.cfterm_id
        SET pre.whos_structure = "PRELIM", pre.section_label = sub_sec.sub_label,
            pre.indent = sub_sec.sub_indent + 1, pre.source = CONCAT( 'Used FINAL struct, ', pre.source )

EXPLAIN on the inner select:

*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: pre
         type: ALL
possible_keys: PRIMARY
          key: NULL
      key_len: NULL
          ref: NULL
         rows: 76
        Extra: Using where; Using filesort
*************************** 2. row ***************************
           id: 1
  select_type: SIMPLE
        table: sub_check
         type: eq_ref
possible_keys: PRIMARY
          key: PRIMARY
      key_len: 5
          ref: ffar_load_a.pre.encore_load,ffar_load_a.pre.cfterm_id_match
         rows: 1
        Extra: Using where
*************************** 3. row ***************************
           id: 1
  select_type: SIMPLE
        table: fin_sec
         type: ref
possible_keys: PRIMARY
          key: PRIMARY
      key_len: 5
          ref: ffar_load_a.pre.encore_load,ffar_load_a.pre.cfterm_id_match
         rows: 2
        Extra: Using index condition

"Using too big key for internal temp tables" query:

UPDATE
  p_prelim_org AS org
JOIN ( SELECT
         encore_load,
         cfterm_id,
         GROUP_CONCAT( CONCAT("[",label,"]") ORDER BY indent ASC SEPARATOR '' ) AS full_label,
         MAX( indent ) + 1 AS indent
       FROM
         p_raw_sections
       GROUP BY
         encore_load, cfterm_id
     ) AS slabels
ON
  org.encore_load = slabels.encore_load AND
  org.cfterm_id = slabels.cfterm_id
  SET org.section_label = slabels.full_label, org.indent = slabels.indent;

Explain on the inner select:

+----+-------------+----------------+------+---------------+------+---------+------+------+----------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------------+------+---------------+------+---------+------+------+----------------+
| 1 | SIMPLE | p_raw_sections | ALL | NULL | NULL | NULL | NULL | 84 | Using filesort |
+----+-------------+----------------+------+---------------+------+---------+------+------+----------------+

CREATE TABLE `p_prelim_org` (
  `encore_load` enum('FIRST','LAST') NOT NULL,
  `table_type` enum('BS','IS','CF') DEFAULT NULL,
  `cfterm_id` int(10) unsigned NOT NULL DEFAULT '0',
  `ordering` smallint(5) unsigned DEFAULT NULL,
  `indent` tinyint(3) unsigned DEFAULT '0',
  `section_label` varchar(2048) DEFAULT '',
  `label` varchar(2048) DEFAULT NULL,
  `status` enum('PRELIM','FINAL','MATCHED') DEFAULT 'PRELIM',
  `cfterm_id_match` int(10) unsigned DEFAULT '0',
  `location` enum('ABOVE','BELOW','UNSET') DEFAULT 'UNSET',
  `whos_structure` enum('PRELIM','FINAL') DEFAULT 'PRELIM',
  `indent_match` tinyint(3) unsigned DEFAULT '0',
  `source` varchar(200) DEFAULT '',
  PRIMARY KEY (`encore_load`,`cfterm_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8

CREATE TABLE `p_raw_sections` (
  `encore_load` enum('FIRST','LAST') NOT NULL,
  `table_type` enum('BS','IS','CF') DEFAULT NULL,
  `cfterm_id` int(10) unsigned NOT NULL DEFAULT '0',
  `indent` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `ordering` smallint(5) unsigned DEFAULT NULL,
  `group_id` tinyint(3) unsigned DEFAULT '0',
  `parent_group` tinyint(3) unsigned DEFAULT '0',
  `label` varchar(2048) DEFAULT NULL,
  PRIMARY KEY (`encore_load`,`cfterm_id`,`indent`),
  KEY `group_id` (`group_id`,`parent_group`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8