Description:
Running a particular query, a REPLACE into a very large table (~2Gb)
causes MySQL to crash with a segmentation fault. I don't know whether the
destination table is corrupt, but myisamchk doesn't think so.
The query is rather long, I'm afraid, so I've elided some fields (also in
the interests of privacy):
REPLACE DELAYED INTO sAll
SELECT YEAR( FROM_UNIXTIME(time)) AS YearNum,
MONTH( FROM_UNIXTIME(time)) AS MonthNum,
DAYOFMONTH(FROM_UNIXTIME(time)) AS DayOfMonth,
WEEK( FROM_UNIXTIME(time)) AS WeekNum,
DAYOFWEEK( FROM_UNIXTIME(time)) AS DayOfWeek,
IFNULL(Category, 'NULL'),
HOUR(FROM_UNIXTIME(time)),
[... various fields ...]
FROMpages200302,sessions200302,users200302
WHERE sessions200302.sessionid = pages200302.sessionid
AND users200302.uid = sessions200302.uid
AND time = UNIX_TIMESTAMP('2003-02-05')
AND time UNIX_TIMESTAMP('2003-02-07')
GROUP BY sAllHash
The table has abourt 4,400,000 rows, and is a MyISAM table. myisamchk does
not detect any errors even with the -e (extended-check) option. I'm
waiting for myisamchk -r to finish so that I can try this query on the
resulting table, but it takes 12 hours to repair.
I have reproduced this with the following MySQL versions:
3.23.55
4.0.10-gamma
4.0.10-gamma-debug-debug
(and 4.0.3 and 4.0.4, I think)
on two different ix86 (Athlons), running Red Hat 7.2 and 7.3 respectively,
both machines well tested and reliable.
How-To-Repeat:
I have a tarball of the necessary files to repeat this. However, it's 1.6 Gb
in size and contains a lot of private data, so I can't distribute it. I'd
be happy to apply patches and follow any steps anyone can suggest to
isolate this.
Stack trace of the segfault:
[root@chris mysql-debug-4.0.10-gamma-pc-linux-i686]# bin/resolve_stack_dump -s
bin/mysqld.sym -n stackdump
0x80720da handle_segfault + 450
0x8295a58 pthread_sighandler + 184
0x806eda5 copy__6StringRC6String + 69
0x804afff copy__16Item_copy_string + 47
0x80a604f copy_fields__FP15TMP_TABLE_PARAM + 67
0x80a2a68 end_send_group__FP4JOINP13st_join_tableb + 676
0x80a14e6 sub_select__FP4JOINP13st_join_tableb + 258
0x80a1193 do_select__FP4JOINPt4List1Z4ItemP8st_tableP9Procedure + 651
0x80990f0
mysql_select__FP3THDP13st_table_listRt4List1Z4ItemP4ItemP8st_orderT4T3T4UlP13select_result
+ 7744
0x8097276 handle_select__FP3THDP6st_lexP13select_result + 102
0x807efb6 mysql_execute_command__Fv + 7870
0x8081316 mysql_parse__FP3THDPcUi + 214
0x807c52a dispatch_command__F19enum_server_commandP3THDPcUi + 1594
0x807bee4 do_command__FP3THD + 420
0x807b54e handle_one_connection + 698
0x829320c pthread_start_thread + 220
0x82c8b1a thread_start + 4
GDB session:
/tmp/mysql-debug-4.0.10-gamma-pc-linux-i686/bin/mysqld: ready for connections.
Version: '4.0.10-gamma-debug-debug' socket: '/tmp/mysql.sock' port: 3306
---Type return to continue, or q return to quit---
Program received signal SIGSEGV, Segmentation fault.
String::copy (this=0x8908ff0, str=@0x88deba8) at sql_string.cc:202
202 sql_string.cc: No such file or directory.
in sql_string.cc
Current language: auto; currently c++
(gdb) info local
this = (String *) 0x35353331
str = (String ) @0x88d2c31: {Ptr = 0x0, str_length = 0, Alloced_length = 0,
alloced = false}
(gdb) up
#1 0x0804afff in Item_copy_string::copy (this=0x8908ff0) at item.cc:294
294 str_value.copy(*res);
(gdb) p item
Cannot access memory at address 0x998abe2
(gdb) info local
this = (Item_copy_string *) 0x8908ff0
res = (class String *) 0xbfffeb2c
(gdb) p *res
$2 = {Ptr = 0x33383331 Address 0x33383331 out of bounds,
str_length = 858860596, Alloced_length = 741619761, alloced = 49}
(gdb) p *this
Cannot access memory at address 0x998abe2
(gdb) up
#2 0x080a604f in copy_fields (param=0xb29c) at sql_select.cc:6981
6981item-copy();
(gdb) info local
param = (TMP_TABLE_PARAM *) 0xb29c
ptr = (class Copy_field *) 0xb2b0
end = (Copy_field *) 0x8902444
it = (List_iterator_fastItem ) @0xb2b0: {base_list_iterator = {
list = 0xb2a0, el = 0x8909024, prev = 0x0,
current = 0x0}, No data fields}
item = (class Item_copy_string *) 0xbfffeb2c
(gdb) up
#3 0x080a2a68 in end_send_group (join=0xbfffee1c, join_tab=0x88ff644,
end_of_records=false) at sql_select.cc:5237
5237 copy_fields(join-tmp_table_param);
(gdb) bt
#0 String::copy (this=0x8908ff0, str=@0x88deba8) at sql_string.cc:202
#1 0x0804afff in Item_copy_string::copy (this=0x8908ff0) at item.cc:294
#2 0x080a604f in copy_fields (param=0xb29c) at sql_select.cc:6981
#3 0x080a2a68 in end_send_group (join=0xbfffee1c, join_tab=0x88ff644,
end_of_records=false) at sql_select.cc:5237
#4 0x080a14e6 in sub_select (join=0xbfffee1c, join_tab=0x88ff528,
end_of_records=false) at sql_select.cc:4550
#5 0x080a1193 in do_select (join=0xbfffee1c, fields=0x88e69d4, table=0x0,
procedure=0x0) at sql_select.cc:4443
#6 0x080990f0 in