Bug #100667 database crash when table is dropping
Submitted: 28 Aug 2020 2:53 Modified: 28 Aug 2020 5:30
Reporter: kfpanda kf Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S6 (Debug Builds)
Version:8.0, 8.0.20 OS:Any
Assigned to: CPU Architecture:Any

[28 Aug 2020 2:53] kfpanda kf
Description:

The following test case crash when a table is dropping.

- drop_table_core.test

```
--source include/have_innodb_max_16k.inc
SET DEFAULT_STORAGE_ENGINE=InnoDB;
LET $prev_innodb_file_per_table = `SELECT @@innodb_file_per_table`;
LET $prev_innodb_strict_mode = `SELECT @@innodb_strict_mode`;

SET GLOBAL innodb_file_per_table = ON;
SET SESSION innodb_strict_mode = OFF;
CREATE TABLE t1(c1 INT PRIMARY KEY) COMPRESSION="zlibX";
ALTER TABLE t1 rename to t2;

--source include/restart_mysqld.inc
DROP TABLE t2;

--echo #
--echo # Cleanup
--echo #
eval SET GLOBAL INNODB_FILE_PER_TABLE=$prev_innodb_file_per_table;
eval SET GLOBAL INNODB_STRICT_MODE=$prev_innodb_strict_mode;

```

How to repeat:
- drop_table_core.test

```
--source include/have_innodb_max_16k.inc
SET DEFAULT_STORAGE_ENGINE=InnoDB;
LET $prev_innodb_file_per_table = `SELECT @@innodb_file_per_table`;
LET $prev_innodb_strict_mode = `SELECT @@innodb_strict_mode`;

SET GLOBAL innodb_file_per_table = ON;
SET SESSION innodb_strict_mode = OFF;
CREATE TABLE t1(c1 INT PRIMARY KEY) COMPRESSION="zlibX";
ALTER TABLE t1 rename to t2;

--source include/restart_mysqld.inc
DROP TABLE t2;

--echo #
--echo # Cleanup
--echo #
eval SET GLOBAL INNODB_FILE_PER_TABLE=$prev_innodb_file_per_table;
eval SET GLOBAL INNODB_STRICT_MODE=$prev_innodb_strict_mode;

```

Suggested fix:
- drop_table_core.test

```
--source include/have_innodb_max_16k.inc
SET DEFAULT_STORAGE_ENGINE=InnoDB;
LET $prev_innodb_file_per_table = `SELECT @@innodb_file_per_table`;
LET $prev_innodb_strict_mode = `SELECT @@innodb_strict_mode`;

SET GLOBAL innodb_file_per_table = ON;
SET SESSION innodb_strict_mode = OFF;
CREATE TABLE t1(c1 INT PRIMARY KEY) COMPRESSION="zlibX";
ALTER TABLE t1 rename to t2;

--source include/restart_mysqld.inc
DROP TABLE t2;

--echo #
--echo # Cleanup
--echo #
eval SET GLOBAL INNODB_FILE_PER_TABLE=$prev_innodb_file_per_table;
eval SET GLOBAL INNODB_STRICT_MODE=$prev_innodb_strict_mode;

```
[28 Aug 2020 2:57] kfpanda kf
Thread 1 (Thread 0x7ff26f889700 (LWP 31601)):
#0  __pthread_kill (threadid=<optimized out>, signo=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
#1  0x000055c22d21d992 in my_write_core (sig=6) at /home/huangyongyao/work/code/ALL_SQL/hwsql/mysys/stacktrace.cc:308
#2  0x000055c22bdb33cb in handle_fatal_signal (sig=6) at /home/huangyongyao/work/code/ALL_SQL/hwsql/sql/signal_handler.cc:171
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#5  0x00007ff26f911801 in __GI_abort () at abort.c:79
#6  0x00007ff26f90139a in __assert_fail_base (fmt=0x7ff26fa887d8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x55c22e62b700 "!atomic || (error != 2 && error != 155)", file=file@entry=0x55c22e62ae18 "/home/huangyongyao/work/code/ALL_SQL/hwsql/sql/sql_table.cc", line=line@entry=2687, function=function@entry=0x55c22e62e5e0 <drop_base_table(THD*, Drop_tables_ctx const&, TABLE_LIST*, bool, std::set<handlerton*, std::less<handlerton*>, std::allocator<handlerton*> >*, Foreign_key_parents_invalidator*, std::vector<MDL_ticket*, std::allocator<MDL_ticket*> >*)::__PRETTY_FUNCTION__> "bool drop_base_table(THD*, const Drop_tables_ctx&, TABLE_LIST*, bool, std::set<handlerton*>*, Foreign_key_parents_invalidator*, std::vector<MDL_ticket*>*)") at assert.c:92
#7  0x00007ff26f901412 in __GI___assert_fail (assertion=0x55c22e62b700 "!atomic || (error != 2 && error != 155)", file=0x55c22e62ae18 "/home/huangyongyao/work/code/ALL_SQL/hwsql/sql/sql_table.cc", line=2687, function=0x55c22e62e5e0 <drop_base_table(THD*, Drop_tables_ctx const&, TABLE_LIST*, bool, std::set<handlerton*, std::less<handlerton*>, std::allocator<handlerton*> >*, Foreign_key_parents_invalidator*, std::vector<MDL_ticket*, std::allocator<MDL_ticket*> >*)::__PRETTY_FUNCTION__> "bool drop_base_table(THD*, const Drop_tables_ctx&, TABLE_LIST*, bool, std::set<handlerton*>*, Foreign_key_parents_invalidator*, std::vector<MDL_ticket*>*)") at assert.c:101
#8  0x000055c22bc79d2d in drop_base_table (thd=0x7ff23fc20000, drop_ctx=..., table=0x7ff23fd50030, atomic=true, post_ddl_htons=0x7ff26f8867e0, fk_invalidator=0x7ff26f886810, safe_to_release_mdl=0x7ff26f885630) at /home/huangyongyao/work/code/ALL_SQL/hwsql/sql/sql_table.cc:2687
#9  0x000055c22bc7ae73 in mysql_rm_table_no_locks (thd=0x7ff23fc20000, tables=0x7ff23fd50030, if_exists=false, drop_temporary=false, drop_database=false, dropped_non_atomic_flag=0x7ff26f886761, post_ddl_htons=0x7ff26f8867e0, fk_invalidator=0x7ff26f886810, safe_to_release_mdl=0x7ff26f886790) at /home/huangyongyao/work/code/ALL_SQL/hwsql/sql/sql_table.cc:3029
#10 0x000055c22bc76ad4 in mysql_rm_table (thd=0x7ff23fc20000, tables=0x7ff23fd50030, if_exists=false, drop_temporary=false) at /home/huangyongyao/work/code/ALL_SQL/hwsql/sql/sql_table.cc:1403
#11 0x000055c22bbc4313 in mysql_execute_command (thd=0x7ff23fc20000, first_level=true) at /home/huangyongyao/work/code/ALL_SQL/hwsql/sql/sql_parse.cc:3482
#12 0x000055c22bbca51c in mysql_parse (thd=0x7ff23fc20000, parser_state=0x7ff26f887c70) at /home/huangyongyao/work/code/ALL_SQL/hwsql/sql/sql_parse.cc:5306
#13 0x000055c22bbbf2c4 in dispatch_command (thd=0x7ff23fc20000, com_data=0x7ff26f888c60, command=COM_QUERY) at /home/huangyongyao/work/code/ALL_SQL/hwsql/sql/sql_parse.cc:1776
#14 0x000055c22bbbd769 in do_command (thd=0x7ff23fc20000) at /home/huangyongyao/work/code/ALL_SQL/hwsql/sql/sql_parse.cc:1274
#15 0x000055c22bd9cf66 in handle_connection (arg=0x7ff241c75b80) at /home/huangyongyao/work/code/ALL_SQL/hwsql/sql/conn_handler/connection_handler_per_thread.cc:302
#16 0x000055c22daa3721 in pfs_spawn_thread (arg=0x7ff26f081b60) at /home/huangyongyao/work/code/ALL_SQL/hwsql/storage/perfschema/pfs.cc:2854
#17 0x00007ff2716366db in start_thread (arg=0x7ff26f889700) at pthread_create.c:463
#18 0x00007ff26f9f288f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
[28 Aug 2020 3:00] kfpanda kf
Test with the DEBUG version
[28 Aug 2020 5:30] MySQL Verification Team
Hello!

Thank you for the report.
Imho this is duplicate of Bug #98593, please see Bug #98593 which is fixed in 8.0.21 release, closed with the below changelog:

In debug mode, a DROP TABLE operation on a table with an incorrectly
defined COMPRESSION clause caused a failure. InnoDB did not return an
error to the caller for proper handling.

-- 8.0.21 - fixed

 ./mtr --debug-server drop_table --nocheck-testcases
Logging: ./mtr  --debug-server drop_table --nocheck-testcases
MySQL Version 8.0.21
Checking supported features
 - Binaries are debug compiled
Using 'all' suites
Collecting tests
Checking leftover processes
Removing old var directory
 - WARNING: Using the 'mysql-test/var' symlink
Creating var directory '/export/umesh/server/binaries/GABuilds/mysql-8.0.21/mysql-test/var'
Installing system database
Using parallel: 1

==============================================================================
                  TEST NAME                       RESULT  TIME (ms) COMMENT
------------------------------------------------------------------------------
SET DEFAULT_STORAGE_ENGINE=InnoDB;
SET GLOBAL innodb_file_per_table = ON;
SET SESSION innodb_strict_mode = OFF;
CREATE TABLE t1(c1 INT PRIMARY KEY) COMPRESSION="zlibx";
Warnings:
Warning 1112    InnoDB: Unsupported compression algorithm 'zlibx'
ALTER TABLE t1 rename to t2;
# restart
DROP TABLE t2;
Warnings:
Warning 1525    Incorrect COMPRESSION value: 'zlibx'
#
# Cleanup
#
SET GLOBAL INNODB_FILE_PER_TABLE=1;
SET GLOBAL INNODB_STRICT_MODE=1;
[ 50%] main.drop_table                           [ pass ]   5841
[100%] shutdown_report                           [ pass ]
------------------------------------------------------------------------------
The servers were restarted 0 times
The servers were reinitialized 0 times
Spent 5.841 of 28 seconds executing testcases

Completed: All 2 tests were successful.

- 8.0.20 - affected

 ./mtr --debug-server drop_table --nocheck-testcases
Logging: ./mtr  --debug-server drop_table --nocheck-testcases
MySQL Version 8.0.20
Checking supported features
 - Binaries are debug compiled
Using 'all' suites
Collecting tests
Checking leftover processes
Removing old var directory
Creating var directory '/export/umesh/server/binaries/GABuilds/mysql-8.0.20/mysql-test/var'
Installing system database
Using parallel: 1

==============================================================================
                  TEST NAME                       RESULT  TIME (ms) COMMENT
------------------------------------------------------------------------------
SET DEFAULT_STORAGE_ENGINE=InnoDB;
SET GLOBAL innodb_file_per_table = ON;
SET SESSION innodb_strict_mode = OFF;
CREATE TABLE t1(c1 INT PRIMARY KEY) COMPRESSION="zlibx";
Warnings:
Warning 1112    InnoDB: Unsupported compression algorithm 'zlibx'
ALTER TABLE t1 rename to t2;
# restart
[100%] main.drop_table                           [ fail ]
        Test ended at 2020-08-28 07:27:50

CURRENT_TEST: main.drop_table
mysqltest: At line 12: Query 'DROP TABLE t2' failed.
ERROR 2013 (HY000): Lost connection to MySQL server during query

Thanks,
Umesh