Bug #20898 out of memory error on select query execution
Submitted: 7 Jul 2006 10:59 Modified: 10 Jul 2006 19:44
Reporter: gaj capuder Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:mysql 5.0.22-community-nt OS:Windows (win 2003)
Assigned to: CPU Architecture:Any

[7 Jul 2006 10:59] gaj capuder
Description:
Mysql reports this error:
Out of memory; restart server and try again (needed 262136 bytes)

There is 0 records in the table. It looks as if there is to many fields in the select the query appears, becouse when i removed some 10 fields it started to work ok.

We also tried same query on MySQL 5.0.19 and the error appeared there aswell but it worked on MySQL 4.1x

How to repeat:
query:

select distinct(`people`.`id`) as table_record_id , `people`.`id` as `id`, `people`.`name` as `name`, `people`.`surname` as `surname`, `people`.`maiden_name` as `maiden_name`, `people`.`picture` as `picture`, `people`.`entry_date` as `entry_date`, `people`.`birth_date` as `birth_date`, `people`.`gender_id` as `gender_id`, `people`.`birthplace` as `birthplace`, `people`.`citizenship` as `citizenship`, `people`.`telephone` as `telephone`, `people`.`gsm` as `gsm`, `people`.`email` as `email`, `people`.`address` as `address`, `people`.`postcode_id` as `postcode_id`, `people`.`temp_address` as `temp_address`, `people`.`temp_postcode_id` as `temp_postcode_id`, `people`.`marital_status_id` as `marital_status_id`, `people`.`nr_children` as `nr_children`, `people`.`child_care_id` as `child_care_id`, `people`.`spouse_employed` as `spouse_employed`, `people`.`spouse_employment` as `spouse_employment`, `people`.`residence_id` as `residence_id`, `people`.`profession_id` as `profession_id`, `people`.`education_level_id` as `education_level_id`, `people`.`title_id` as `title_id`, `people`.`previous_education` as `previous_education`, `people`.`professional_courses` as `professional_courses`, `people`.`recommence_schooling` as `recommence_schooling`, `people`.`next_education` as `next_education`, `people`.`computer_knowledge` as `computer_knowledge`, `people`.`smoker` as `smoker`, `people`.`drivers_license` as `drivers_license`, `people`.`working_years` as `working_years`, `people`.`expected_wages` as `expected_wages`, `people`.`employment_agency` as `employment_agency`, `people`.`employment_agency_from` as `employment_agency_from`, `people`.`financial_support` as `financial_support`, `people`.`disability` as `disability`, `people`.`afternoon_work_id` as `afternoon_work_id`, `people`.`professional_ambitions` as `professional_ambitions`, `people`.`leisure` as `leisure`, `people`.`interests` as `interests`, `people`.`interview` as `interview`, `people`.`interviewer` as `interviewer`, `people`.`interview_date` as `interview_date`, `people`.`grade_id` as `grade_id`, `people`.`entry_by` as `entry_by`, `people`.`comments` as `comments`, `people`.`reference_id` as `reference_id`, `people`.`opinion` as `opinion`, `people`.`suitable_work` as `suitable_work` from `people` order by surname ASC, name ASC limit 0,50 

table structure:

CREATE TABLE `people` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(255) collate utf8_slovenian_ci NOT NULL,
  `surname` varchar(255) collate utf8_slovenian_ci NOT NULL,
  `maiden_name` varchar(255) collate utf8_slovenian_ci NOT NULL,
  `picture` varchar(255) collate utf8_slovenian_ci NOT NULL,
  `entry_date` date NOT NULL,
  `birth_date` date NOT NULL,
  `gender_id` int(11) NOT NULL,
  `birthplace` varchar(255) collate utf8_slovenian_ci NOT NULL,
  `citizenship` tinyint(1) NOT NULL,
  `telephone` varchar(255) collate utf8_slovenian_ci NOT NULL,
  `gsm` varchar(255) collate utf8_slovenian_ci NOT NULL,
  `email` varchar(255) collate utf8_slovenian_ci NOT NULL,
  `address` varchar(255) collate utf8_slovenian_ci NOT NULL,
  `postcode_id` int(11) NOT NULL,
  `temp_address` varchar(255) collate utf8_slovenian_ci NOT NULL,
  `temp_postcode_id` int(11) NOT NULL,
  `marital_status_id` int(11) NOT NULL,
  `nr_children` int(11) NOT NULL,
  `child_care_id` int(11) NOT NULL,
  `spouse_employed` tinyint(1) NOT NULL,
  `spouse_employment` varchar(255) collate utf8_slovenian_ci NOT NULL,
  `residence_id` int(11) NOT NULL,
  `profession_id` int(11) NOT NULL,
  `education_level_id` int(11) NOT NULL,
  `title_id` int(11) NOT NULL,
  `previous_education` varchar(255) collate utf8_slovenian_ci NOT NULL,
  `professional_courses` text collate utf8_slovenian_ci NOT NULL,
  `recommence_schooling` tinyint(1) NOT NULL,
  `next_education` text collate utf8_slovenian_ci NOT NULL,
  `computer_knowledge` tinyint(1) NOT NULL,
  `smoker` tinyint(1) NOT NULL,
  `drivers_license` tinyint(1) NOT NULL,
  `working_years` float NOT NULL,
  `expected_wages` float NOT NULL,
  `employment_agency` tinyint(1) NOT NULL,
  `employment_agency_from` date NOT NULL,
  `financial_support` float NOT NULL,
  `disability` tinyint(1) NOT NULL,
  `afternoon_work_id` int(11) NOT NULL,
  `professional_ambitions` text collate utf8_slovenian_ci NOT NULL,
  `leisure` text collate utf8_slovenian_ci NOT NULL,
  `interests` text collate utf8_slovenian_ci NOT NULL,
  `interview` tinyint(1) NOT NULL,
  `interviewer` int(11) NOT NULL,
  `interview_date` date NOT NULL,
  `grade_id` int(11) NOT NULL,
  `entry_by` int(11) NOT NULL,
  `comments` text collate utf8_slovenian_ci NOT NULL,
  `reference_id` int(11) NOT NULL,
  `opinion` text collate utf8_slovenian_ci NOT NULL,
  `suitable_work` text collate utf8_slovenian_ci NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `gender_id` (`gender_id`),
  KEY `postcode_id` (`postcode_id`),
  KEY `temp_postcode_id` (`temp_postcode_id`),
  KEY `marital_status_id` (`marital_status_id`),
  KEY `child_care_id` (`child_care_id`),
  KEY `residence_id` (`residence_id`),
  KEY `profession_id` (`profession_id`),
  KEY `education_level_id` (`education_level_id`),
  KEY `title_id` (`title_id`),
  KEY `afternoon_work_id` (`afternoon_work_id`),
  KEY `interviewer` (`interviewer`),
  KEY `entry_by` (`entry_by`),
  KEY `grade_id` (`grade_id`),
  KEY `reference_id` (`reference_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_slovenian_ci AUTO_INCREMENT=2 ;
[7 Jul 2006 11:29] Tonci Grgin
Hi Gaj and thanks for your problem report.
I was unable to repeat it on Win XP Pro SP2 and on Suse 10. 
If you have any more info you can provide on this matter, please do so and reopen the report.
[7 Jul 2006 11:30] Tonci Grgin
Test results

Attachment: 20898.txt (message/rfc822, text), 14.36 KiB.

[7 Jul 2006 11:40] Tonci Grgin
Gaj, can you please attach your my.ini file to this report and provide more machine info?
[7 Jul 2006 12:40] gaj capuder
my.ini

Attachment: my.ini (application/octet-stream, text), 8.93 KiB.

[7 Jul 2006 12:42] gaj capuder
The server is running on Windows 2003 small business. I just found out that the query works ok if i remove the LIMIT statement and it also works if i remove a couple of fields in select. Strange behaviour. :)
[10 Jul 2006 17:51] MySQL Verification Team
I got this error on w2ksp4:

mysql> select distinct(`people`.`id`) as table_record_id , `people`.`id` as <snip>
    -> from `people` order by surname ASC, name ASC limit 0,50 ;
ERROR 1037 (HY001): Out of memory; restart server and try again (needed 262136 bytes)
mysql>

Version: '5.0.22-community-nt'  socket: ''  port: 3306  MySQL Community Edition (GPL)
060710 19:47:57 [ERROR] mysqld-nt: Out of memory; restart server and try again (needed 262136 bytes)
060710 19:47:57 [ERROR] mysqld-nt: Sort aborted
[10 Jul 2006 19:44] MySQL Verification Team
Can't repeat using latest 5.0-bk source. Anyway, the problem can be alleviated in 5.0.22 by increasing the sort_buffer_size variable for the current session, or globally.