Bug #74641 my_seek.c:57: my_seek: Assertion `fd != -1' failed. Table corruption on opt
Submitted: 31 Oct 2014 1:31 Modified: 31 Oct 2014 14:41
Reporter: Roel Van de Paar Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S1 (Critical)
Version:5.6.20, 5.6.21 OS:Any
Assigned to: CPU Architecture:Any
Tags: debug crash, opt

[31 Oct 2014 1:31] Roel Van de Paar
Description:
Optimized
mysql> alter table t1 ENGINE=INNODB;
ERROR 1194 (HY000): Table 't1' is marked as crashed and should be repaired

Debug
mysql> alter table t1 ENGINE=INNODB;
ERROR 2013 (HY000): Lost connection to MySQL server during query

(gdb) bt
#0  0x00007ffb13473771 in pthread_kill () from /lib64/libpthread.so.0
#1  0x0000000000a9035e in my_write_core (sig=6) at /bzr/mysql-5.6/mysys/stacktrace.c:422
#2  0x0000000000723688 in handle_fatal_signal (sig=6) at /bzr/mysql-5.6/sql/signal_handler.cc:230
#3  <signal handler called>
#4  0x00007ffb1227f5c9 in raise () from /lib64/libc.so.6
#5  0x00007ffb12280cd8 in abort () from /lib64/libc.so.6
#6  0x00007ffb12278536 in __assert_fail_base () from /lib64/libc.so.6
#7  0x00007ffb122785e2 in __assert_fail () from /lib64/libc.so.6
#8  0x0000000000a8c5bf in my_seek (fd=-1, pos=0, whence=0, MyFlags=0) at /bzr/mysql-5.6/mysys/my_seek.c:57
#9  0x0000000000af2909 in azrewind (s=0x7ffa489e0db8) at /bzr/mysql-5.6/storage/archive/azio.c:673
#10 0x0000000000aec7a1 in ha_archive::read_data_header (this=0x7ffa489e0b70, file_to_read=0x7ffa489e0db8) at /bzr/mysql-5.6/storage/archive/ha_archive.cc:403
#11 0x0000000000aee690 in ha_archive::rnd_init (this=0x7ffa489e0b70, scan=true) at /bzr/mysql-5.6/storage/archive/ha_archive.cc:1176
#12 0x000000000063827b in handler::ha_rnd_init (this=0x7ffa489e0b70, scan=true) at /bzr/mysql-5.6/sql/handler.cc:2641
#13 0x0000000000e0b618 in ha_partition::rnd_next (this=0x7ffa667edb50, buf=0x7ffa6568d650 "\377") at /bzr/mysql-5.6/sql/ha_partition.cc:4742
#14 0x00000000006384d8 in handler::ha_rnd_next (this=0x7ffa667edb50, buf=0x7ffa6568d650 "\377") at /bzr/mysql-5.6/sql/handler.cc:2687
#15 0x000000000097676a in rr_sequential (info=0x7ffa7d26b400) at /bzr/mysql-5.6/sql/records.cc:478
#16 0x000000000084412b in copy_data_between_tables (from=0x7ffa66e6e8e0, to=0x7ffa667eb910, create=..., ignore=false, order_num=0, order=0x0, copied=0x7ffa7d26d370, deleted=0x7ffa7d26d368, keys_onoff=Alter_info::LEAVE_AS_IS, alter_ctx=0x7ffa7d26c890) at /bzr/mysql-5.6/sql/sql_table.cc:8956
#17 0x0000000000842988 in mysql_alter_table (thd=0x26550c0, new_db=0x7ffa64005640 "test", new_name=0x0, create_info=0x7ffa7d26d720, table_list=0x7ffa640050e0, alter_info=0x7ffa7d26d690, order_num=0, order=0x0, ignore=false) at /bzr/mysql-5.6/sql/sql_table.cc:8516
#18 0x000000000098177f in Sql_cmd_alter_table::execute (this=0x7ffa64005650, thd=0x26550c0) at /bzr/mysql-5.6/sql/sql_alter.cc:313
#19 0x00000000007d5ea3 in mysql_execute_command (thd=0x26550c0) at /bzr/mysql-5.6/sql/sql_parse.cc:4945
#20 0x00000000007d8fa4 in mysql_parse (thd=0x26550c0, rawbuf=0x7ffa64004ff0 "alter table t1 ENGINE=INNODB", length=28, parser_state=0x7ffa7d26eeb0) at /bzr/mysql-5.6/sql/sql_parse.cc:6245
#21 0x00000000007cc557 in dispatch_command (command=COM_QUERY, thd=0x26550c0, packet=0x82f46e1 "alter table t1 ENGINE=INNODB", packet_length=28) at /bzr/mysql-5.6/sql/sql_parse.cc:1332
#22 0x00000000007cb646 in do_command (thd=0x26550c0) at /bzr/mysql-5.6/sql/sql_parse.cc:1034
#23 0x0000000000793a61 in do_handle_one_connection (thd_arg=0x26550c0) at /bzr/mysql-5.6/sql/sql_connect.cc:982
#24 0x000000000079354a in handle_one_connection (arg=0x26550c0) at /bzr/mysql-5.6/sql/sql_connect.cc:898
#25 0x0000000000ade888 in pfs_spawn_thread (arg=0x81ae250) at /bzr/mysql-5.6/storage/perfschema/pfs.cc:1860
#26 0x00007ffb1346edf3 in start_thread () from /lib64/libpthread.so.0
#27 0x00007ffb1234001d in clone () from /lib64/libc.so.6

How to repeat:
DROP DATABASE test;CREATE DATABASE test;USE test;
SET storage_engine=archive;
create table t1(a int)partition by hash (a) partitions 2;
ALTER TABLE t1 ADD PARTITION PARTITIONS 600;
alter table t1 ENGINE=INNODB;
[31 Oct 2014 14:41] MySQL Verification Team
Hello Roel,

Thank you for the report and test case.
Confirmed the issue on 5.6.21 debug build.

Thanks,
Umesh
[31 Oct 2014 14:41] MySQL Verification Team
// 5.6.21 debug build

[root@cluster-repo mysql-5.6.21]# valgrind --track-origins=yes --track-fds=yes -v --show-reachable=yes --leak-check=full --num-callers=50 --db-attach=yes --tool=memcheck /data/ushastry/server/mysql-5.6.21/bin/mysqld-debug --no-defaults --basedir=/data/ushastry/server/mysql-5.6.21 --datadir=/tmp/bug  --core-file --socket=/tmp/mysql.sock  --port=3306 --log-error=/tmp/bug/log.err --user=root

[root@cluster-repo mysql-5.6.21]# bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.21-debug MySQL Community Server - Debug (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> DROP DATABASE test;CREATE DATABASE test;USE test;
Query OK, 0 rows affected (0.35 sec)

Query OK, 1 row affected (0.04 sec)

Database changed
mysql> SET storage_engine=archive;
Query OK, 0 rows affected, 1 warning (0.08 sec)

mysql> create table t1(a int)partition by hash (a) partitions 2;
Query OK, 0 rows affected (0.69 sec)

mysql> ALTER TABLE t1 ADD PARTITION PARTITIONS 600;
Query OK, 0 rows affected (10.40 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> alter table t1 ENGINE=INNODB;
ERROR 2013 (HY000): Lost connection to MySQL server during query

(gdb) bt
#0  0x0000000004e3b8ac in pthread_kill () from /lib64/libpthread.so.0
#1  0x0000000000aaa203 in my_write_core (sig=6) at /export/home/pb2/build/sb_0-13191046-1410443906.78/mysql-5.6.21/mysys/stacktrace.c:422
#2  0x00000000007140ea in handle_fatal_signal (sig=6) at /export/home/pb2/build/sb_0-13191046-1410443906.78/mysql-5.6.21/sql/signal_handler.cc:230
#3  <signal handler called>
#4  0x0000000005945625 in raise () from /lib64/libc.so.6
#5  0x0000000005946e05 in abort () from /lib64/libc.so.6
#6  0x000000000593e74e in __assert_fail_base () from /lib64/libc.so.6
#7  0x000000000593e810 in __assert_fail () from /lib64/libc.so.6
#8  0x0000000000aa6336 in my_seek (fd=-1, pos=0, whence=0, MyFlags=0) at /export/home/pb2/build/sb_0-13191046-1410443906.78/mysql-5.6.21/mysys/my_seek.c:57
#9  0x0000000000ac322f in azrewind (s=0x243dfb58) at /export/home/pb2/build/sb_0-13191046-1410443906.78/mysql-5.6.21/storage/archive/azio.c:673
#10 0x0000000000abf2e5 in ha_archive::read_data_header (this=0x243df910, file_to_read=0x243dfb58)
    at /export/home/pb2/build/sb_0-13191046-1410443906.78/mysql-5.6.21/storage/archive/ha_archive.cc:403
#11 0x0000000000abf8b5 in ha_archive::rnd_init (this=0x243df910, scan=true) at /export/home/pb2/build/sb_0-13191046-1410443906.78/mysql-5.6.21/storage/archive/ha_archive.cc:1176
#12 0x0000000000618fd6 in handler::ha_rnd_init (this=0x243df910, scan=true) at /export/home/pb2/build/sb_0-13191046-1410443906.78/mysql-5.6.21/sql/handler.cc:2641
#13 0x0000000000e0ffde in ha_partition::rnd_next (this=0x19a0a710, buf=0x228894f0 "\377") at /export/home/pb2/build/sb_0-13191046-1410443906.78/mysql-5.6.21/sql/ha_partition.cc:4742
#14 0x00000000006188dc in handler::ha_rnd_next (this=0x19a0a710, buf=0x228894f0 "\377") at /export/home/pb2/build/sb_0-13191046-1410443906.78/mysql-5.6.21/sql/handler.cc:2687
#15 0x000000000097cf4a in rr_sequential (info=0x40afac0) at /export/home/pb2/build/sb_0-13191046-1410443906.78/mysql-5.6.21/sql/records.cc:478
#16 0x000000000082b048 in copy_data_between_tables (from=0x13ff7990, to=0x204c5eb0, create=..., ignore=false, order_num=0, order=0x0, copied=0x40b1360, deleted=0x40b1358,
    keys_onoff=Alter_info::LEAVE_AS_IS, alter_ctx=0x40afd30) at /export/home/pb2/build/sb_0-13191046-1410443906.78/mysql-5.6.21/sql/sql_table.cc:8956
#17 0x0000000000837ded in mysql_alter_table (thd=0x19cade10, new_db=0x19cb66c0 "test", new_name=0x0, create_info=0x40b1bd0, table_list=0x19cb6160, alter_info=0x40b1cb0, order_num=0, order=0x0,
    ignore=false) at /export/home/pb2/build/sb_0-13191046-1410443906.78/mysql-5.6.21/sql/sql_table.cc:8512
#18 0x0000000000989611 in Sql_cmd_alter_table::execute (this=0x19cb66d0, thd=0x19cade10) at /export/home/pb2/build/sb_0-13191046-1410443906.78/mysql-5.6.21/sql/sql_alter.cc:313
#19 0x00000000007ce4b7 in mysql_execute_command (thd=0x19cade10) at /export/home/pb2/build/sb_0-13191046-1410443906.78/mysql-5.6.21/sql/sql_parse.cc:4945
#20 0x00000000007cee85 in mysql_parse (thd=0x19cade10, rawbuf=0x19cb6070 "alter table t1 ENGINE=INNODB", length=28, parser_state=0x40b3680)
    at /export/home/pb2/build/sb_0-13191046-1410443906.78/mysql-5.6.21/sql/sql_parse.cc:6245
#21 0x00000000007d0a2f in dispatch_command (command=COM_QUERY, thd=0x19cade10, packet=0x19985fd1 "alter table t1 ENGINE=INNODB", packet_length=28)
    at /export/home/pb2/build/sb_0-13191046-1410443906.78/mysql-5.6.21/sql/sql_parse.cc:1332
#22 0x00000000007d2269 in do_command (thd=0x19cade10) at /export/home/pb2/build/sb_0-13191046-1410443906.78/mysql-5.6.21/sql/sql_parse.cc:1034
#23 0x0000000000788571 in do_handle_one_connection (thd_arg=0x19cade10) at /export/home/pb2/build/sb_0-13191046-1410443906.78/mysql-5.6.21/sql/sql_connect.cc:982
#24 0x0000000000788637 in handle_one_connection (arg=0x19cade10) at /export/home/pb2/build/sb_0-13191046-1410443906.78/mysql-5.6.21/sql/sql_connect.cc:898
#25 0x0000000000d9bbe2 in pfs_spawn_thread (arg=0x19cb1890) at /export/home/pb2/build/sb_0-13191046-1410443906.78/mysql-5.6.21/storage/perfschema/pfs.cc:1860
#26 0x0000000004e369d1 in start_thread () from /lib64/libpthread.so.0
#27 0x00000000059fb9dd in clone () from /lib64/libc.so.6
[31 Oct 2014 14:41] MySQL Verification Team
// 5.6.21 optimized build

[ushastry@cluster-repo mysql-5.6.21]$ valgrind --track-origins=yes --track-fds=yes -v --show-reachable=yes --leak-check=full --num-callers=50 --db-attach=yes --tool=memcheck /data/ushastry/server/mysql-5.6.21/bin/mysqld --no-defaults --basedir=/data/ushastry/server/mysql-5.6.21 --datadir=/tmp/bug  --gdb --socket=/tmp/mysql.sock  --port=3306 --log-error=/tmp/bug/log.err --user=root
==11993== Memcheck, a memory error detector

[root@cluster-repo mysql-5.6.21]# bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.21 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> DROP DATABASE test;CREATE DATABASE test;USE test;
Query OK, 0 rows affected (0.20 sec)

Query OK, 1 row affected (0.02 sec)

Database changed
mysql> SET storage_engine=archive;
Query OK, 0 rows affected, 1 warning (0.05 sec)

mysql> create table t1(a int)partition by hash (a) partitions 2;
Query OK, 0 rows affected (0.41 sec)

mysql> ALTER TABLE t1 ADD PARTITION PARTITIONS 600;
Query OK, 0 rows affected (6.80 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> alter table t1 ENGINE=INNODB;
ERROR 1194 (HY000): Table 't1' is marked as crashed and should be repaired
mysql>