Bug #80745 Segmentation fault while altering table engine to innodb from memory engine

Submitted: 15 Mar 2016 11:34 Modified: 6 May 2016 10:48
Reporter: Shahriyar Rzayev Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S1 (Critical)
Version:5.7.11 OS:Any
Assigned to: CPU Architecture:Any

[15 Mar 2016 11:34] Shahriyar Rzayev
Description:
Hi dear experts.

As simple as possible - tested with MySQL 5.7.11 debug-valgrind

create tablespace s1 add datafile 's1.ibd' engine=innodb;

CREATE TABLE `sbtest2` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `k` int(10) unsigned NOT NULL DEFAULT '0',
  `c` char(120) NOT NULL DEFAULT '',
  `pad` char(60) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`),
  KEY `k_1` (`k`)
) /*!50100 TABLESPACE `s1` */ ENGINE=MEMORY DEFAULT CHARSET=utf8 MAX_ROWS=1000000 COMPRESSION='zlib' ENCRYPTION='y';

mysql> alter table sbtest2 engine=innodb;
ERROR 2013 (HY000): Lost connection to MySQL server during query

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007fb1d67ea621 in __pthread_kill (threadid=<optimized out>, signo=11) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:61
61	../nptl/sysdeps/unix/sysv/linux/pthread_kill.c: No such file or directory.
(gdb) bt
#0  0x00007fb1d67ea621 in __pthread_kill (threadid=<optimized out>, signo=11) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:61
#1  0x000000000186b1d9 in my_write_core (sig=11) at /opt/mysql-5.7.11/mysys/stacktrace.c:247
#2  0x0000000000e6bb52 in handle_fatal_signal (sig=11) at /opt/mysql-5.7.11/sql/signal_handler.cc:220
#3  <signal handler called>
#4  0x00000000018f2fa7 in ut_allocator<unsigned char>::deallocate_trace (this=0x7fb1936eed90, pfx=0x4d1ffffffe8) at /opt/mysql-5.7.11/storage/innobase/include/ut0new.h:726
#5  0x00000000018f0e4c in ut_allocator<unsigned char>::deallocate (this=0x7fb1936eed90, ptr=0x4d200000000 <error: Cannot access memory at address 0x4d200000000>, n_elements=0)
    at /opt/mysql-5.7.11/storage/innobase/include/ut0new.h:402
#6  0x0000000001bf6cef in dict_mem_table_free (table=0x7fb148921890) at /opt/mysql-5.7.11/storage/innobase/dict/dict0mem.cc:212
#7  0x00000000018ef159 in create_table_info_t::create_table_def (this=0x7fb1936ef2e0) at /opt/mysql-5.7.11/storage/innobase/handler/ha_innodb.cc:10044
#8  0x00000000018db93a in create_table_info_t::create_table (this=0x7fb1936ef2e0) at /opt/mysql-5.7.11/storage/innobase/handler/ha_innodb.cc:11567
#9  0x00000000018dc534 in ha_innobase::create (this=0x7fb148920840, name=0x7fb1936f2174 "./test/#sql-12bf_2", form=0x7fb1936efad0, create_info=0x7fb1936f24f0)
    at /opt/mysql-5.7.11/storage/innobase/handler/ha_innodb.cc:11917
#10 0x0000000000ef1c9e in handler::ha_create (this=0x7fb148920840, name=0x7fb1936f2174 "./test/#sql-12bf_2", form=0x7fb1936efad0, info=0x7fb1936f24f0)
    at /opt/mysql-5.7.11/sql/handler.cc:4819
#11 0x0000000000ef22b9 in ha_create_table (thd=0x7fb148000b70, path=0x7fb1936f2174 "./test/#sql-12bf_2", db=0x7fb148004a10 "test", table_name=0x7fb1936f1920 "#sql-12bf_2", 
    create_info=0x7fb1936f24f0, update_create_info=false, is_temp_table=false) at /opt/mysql-5.7.11/sql/handler.cc:4978
#12 0x00000000015a8374 in mysql_alter_table (thd=0x7fb148000b70, new_db=0x7fb148004a10 "test", new_name=0x0, create_info=0x7fb1936f24f0, table_list=0x7fb14891d820, 
    alter_info=0x7fb1936f2440) at /opt/mysql-5.7.11/sql/sql_table.cc:9572
#13 0x00000000017300e7 in Sql_cmd_alter_table::execute (this=0x7fb14800e5b0, thd=0x7fb148000b70) at /opt/mysql-5.7.11/sql/sql_alter.cc:316
#14 0x000000000150f2f5 in mysql_execute_command (thd=0x7fb148000b70, first_level=true) at /opt/mysql-5.7.11/sql/sql_parse.cc:4806
#15 0x00000000015112e2 in mysql_parse (thd=0x7fb148000b70, parser_state=0x7fb1936f41d0) at /opt/mysql-5.7.11/sql/sql_parse.cc:5518
#16 0x0000000001506394 in dispatch_command (thd=0x7fb148000b70, com_data=0x7fb1936f4dd0, command=COM_QUERY) at /opt/mysql-5.7.11/sql/sql_parse.cc:1428
#17 0x00000000015052ed in do_command (thd=0x7fb148000b70) at /opt/mysql-5.7.11/sql/sql_parse.cc:996
#18 0x00000000016439af in handle_connection (arg=0x48dd210) at /opt/mysql-5.7.11/sql/conn_handler/connection_handler_per_thread.cc:301
#19 0x0000000001cc0a3f in pfs_spawn_thread (arg=0x4b30a30) at /opt/mysql-5.7.11/storage/perfschema/pfs.cc:2192
#20 0x00007fb1d67e5182 in start_thread (arg=0x7fb1936f5700) at pthread_create.c:312
#21 0x00007fb1d5cf247d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

How to repeat:
see description

Suggested fix:
no idea
[15 Mar 2016 12:17] MySQL Verification Team
Hello Shahriyar,

Thank you for the report.

Thanks,
Umesh
[15 Mar 2016 12:18] MySQL Verification Team
-- Only debug build is affected

-- Single user can be used for all steps(just used to see if more pri required)
-- As a root

mysql> create user 'bug'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL  ON db1.* TO 'bug'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE TABLESPACE `s1` ADD DATAFILE 'ts1.ibd' ENGINE=INNODB;
Query OK, 0 rows affected (0.00 sec)

mysql> create database db1;
Query OK, 1 row affected (0.01 sec)

-- As a bug user

[umshastr@hod03]/export/umesh/server/binaries/mysql-5.7.11: bin/mysql -ubug -S/tmp/mysql_ushastry.sock
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.11 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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> use db1
Database changed
mysql> DROP TABLE IF EXISTS sbtest1;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> CREATE TABLE `sbtest1` (
    ->   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    ->   `k` int(10) unsigned NOT NULL DEFAULT '0',
    ->   `c` char(120) NOT NULL DEFAULT '',
    ->   `pad` char(60) NOT NULL DEFAULT '',
    ->   PRIMARY KEY (`id`),
    ->   KEY `k_1` (`k`)
    -> ) ENGINE=InnoDB TABLESPACE=s1 AUTO_INCREMENT=685441 DEFAULT CHARSET=utf8 MAX_ROWS=1000000;
Query OK, 0 rows affected (0.01 sec)

mysql> alter table sbtest1 engine=memory;
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> alter table sbtest1 encryption='y';
Query OK, 0 rows affected (0.00 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> alter table sbtest1 compression='zlib';
Query OK, 0 rows affected (0.00 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> show create table sbtest1\G
*************************** 1. row ***************************
       Table: sbtest1
Create Table: CREATE TABLE `sbtest1` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `k` int(10) unsigned NOT NULL DEFAULT '0',
  `c` char(120) NOT NULL DEFAULT '',
  `pad` char(60) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`),
  KEY `k_1` (`k`)
) /*!50100 TABLESPACE `s1` */ ENGINE=MEMORY AUTO_INCREMENT=685441 DEFAULT CHARSET=utf8 MAX_ROWS=1000000 COMPRESSION='zlib' ENCRYPTION='y'
1 row in set (0.00 sec)

-- With release build

mysql> alter table sbtest1 engine=innodb;
ERROR 3183 (HY000): This tablespace can't be encrypted.

-- With debug build

mysql> alter table sbtest1 engine=innodb;
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> \q

(gdb) bt
#0  0x00007f675dcf5771 in pthread_kill () from /lib64/libpthread.so.0
#1  0x00000000017aa0cd in my_write_core (sig=6) at /export/home/pb2/build/sb_0-17781605-1454370718.35/mysql-5.7.11/mysys/stacktrace.c:247
#2  0x0000000000d8b058 in handle_fatal_signal (sig=6) at /export/home/pb2/build/sb_0-17781605-1454370718.35/mysql-5.7.11/sql/signal_handler.cc:220
#3  <signal handler called>
#4  0x00007f675c8fb5d7 in raise () from /lib64/libc.so.6
#5  0x00007f675c8fccc8 in abort () from /lib64/libc.so.6
#6  0x0000000001a337a7 in ut_dbg_assertion_failed (expr=0x2211a10 "block->magic_n == MEM_BLOCK_MAGIC_N",
    file=0x2211978 "/export/home/pb2/build/sb_0-17781605-1454370718.35/mysql-5.7.11/storage/innobase/include/mem0mem.ic", line=157)
    at /export/home/pb2/build/sb_0-17781605-1454370718.35/mysql-5.7.11/storage/innobase/ut/ut0dbg.cc:67
#7  0x0000000001afaf7e in mem_block_validate (block=0x7f66d491f5c8) at /export/home/pb2/build/sb_0-17781605-1454370718.35/mysql-5.7.11/storage/innobase/include/mem0mem.ic:157
#8  0x0000000001afb22f in mem_heap_free (heap=0x7f66d491f5c8) at /export/home/pb2/build/sb_0-17781605-1454370718.35/mysql-5.7.11/storage/innobase/include/mem0mem.ic:523
#9  0x0000000001afc4c3 in dict_mem_table_free (table=0x7f66d491f760) at /export/home/pb2/build/sb_0-17781605-1454370718.35/mysql-5.7.11/storage/innobase/dict/dict0mem.cc:224
#10 0x00000000018164b9 in create_table_info_t::create_table_def (this=0x7f671a7acab0)
    at /export/home/pb2/build/sb_0-17781605-1454370718.35/mysql-5.7.11/storage/innobase/handler/ha_innodb.cc:10044
#11 0x00000000018039e8 in create_table_info_t::create_table (this=0x7f671a7acab0) at /export/home/pb2/build/sb_0-17781605-1454370718.35/mysql-5.7.11/storage/innobase/handler/ha_innodb.cc:11567
#12 0x000000000180464d in ha_innobase::create (this=0x7f66d4011d90, name=0x7f671a7ae454 "./db1/#sql-2a9c_2", form=0x7f671a7acc00, create_info=0x7f671a7afc40)
    at /export/home/pb2/build/sb_0-17781605-1454370718.35/mysql-5.7.11/storage/innobase/handler/ha_innodb.cc:11917
#13 0x0000000000e0cc76 in handler::ha_create (this=0x7f66d4011d90, name=0x7f671a7ae454 "./db1/#sql-2a9c_2", form=0x7f671a7acc00, info=0x7f671a7afc40)
    at /export/home/pb2/build/sb_0-17781605-1454370718.35/mysql-5.7.11/sql/handler.cc:4819
#14 0x0000000000e0d2a5 in ha_create_table (thd=0x7f66d4000b70, path=0x7f671a7ae454 "./db1/#sql-2a9c_2", db=0x7f66d40064b8 "db1", table_name=0x7f671a7adc00 "#sql-2a9c_2",
    create_info=0x7f671a7afc40, update_create_info=false, is_temp_table=false) at /export/home/pb2/build/sb_0-17781605-1454370718.35/mysql-5.7.11/sql/handler.cc:4978
#15 0x00000000014f1723 in mysql_alter_table (thd=0x7f66d4000b70, new_db=0x7f66d40064b8 "db1", new_name=0x0, create_info=0x7f671a7afc40, table_list=0x7f66d4005f30, alter_info=0x7f671a7afd40)
    at /export/home/pb2/build/sb_0-17781605-1454370718.35/mysql-5.7.11/sql/sql_table.cc:9570
#16 0x0000000001679969 in Sql_cmd_alter_table::execute (this=0x7f66d40064c8, thd=0x7f66d4000b70) at /export/home/pb2/build/sb_0-17781605-1454370718.35/mysql-5.7.11/sql/sql_alter.cc:316
#17 0x000000000145ccfe in mysql_execute_command (thd=0x7f66d4000b70, first_level=true) at /export/home/pb2/build/sb_0-17781605-1454370718.35/mysql-5.7.11/sql/sql_parse.cc:4806
#18 0x000000000145ec61 in mysql_parse (thd=0x7f66d4000b70, parser_state=0x7f671a7b1690) at /export/home/pb2/build/sb_0-17781605-1454370718.35/mysql-5.7.11/sql/sql_parse.cc:5518
#19 0x0000000001453776 in dispatch_command (thd=0x7f66d4000b70, com_data=0x7f671a7b1e00, command=COM_QUERY)
    at /export/home/pb2/build/sb_0-17781605-1454370718.35/mysql-5.7.11/sql/sql_parse.cc:1428
#20 0x0000000001452631 in do_command (thd=0x7f66d4000b70) at /export/home/pb2/build/sb_0-17781605-1454370718.35/mysql-5.7.11/sql/sql_parse.cc:996
#21 0x0000000001588c6d in handle_connection (arg=0x4ee26a0) at /export/home/pb2/build/sb_0-17781605-1454370718.35/mysql-5.7.11/sql/conn_handler/connection_handler_per_thread.cc:301
#22 0x0000000001bc0c75 in pfs_spawn_thread (arg=0x5032610) at /export/home/pb2/build/sb_0-17781605-1454370718.35/mysql-5.7.11/storage/perfschema/pfs.cc:2192
#23 0x00007f675dcf0df5 in start_thread () from /lib64/libpthread.so.0
#24 0x00007f675c9bc60d in clone () from /lib64/libc.so.6
(gdb)
[15 Mar 2016 22:55] Roel Van de Paar
ERROR 3183 (HY000): This tablespace can't be encrypted.

This looks incorrect in release build too (it's either already encrypted as shown or encryption is not possible for MEMORY, or ... :)
[6 May 2016 10:48] Erlend Dahl
Fixed in 5.7.13 along with 

Bug#80182 Unsupported extension error for new features while 'create table like'

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.057 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.