Bug #91823 innodb.innodb test leads to crash on MySQL 8.0.12
Submitted: 29 Jul 2018 18:25 Modified: 28 Oct 2018 22:02
Reporter: Valeriy Kravchuk Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:8.0.12 OS:Ubuntu (14.04)
Assigned to: CPU Architecture:x86

[29 Jul 2018 18:25] Valeriy Kravchuk
Description:
I've build MySQL 8.0.12 from GitHub source on up to date 64-bit Ubuntu 14.04 with the following cmake command line:

cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_CONFIG=mysql_release -DFEATURE_SET=community -DWITH_EMBEDDED_SERVER=OFF -DCMAKE_INSTALL_PREFIX=/home/openxs/dbs/8.0 -DWITH_BOOST=/home/openxs/boost -DDOWNLOAD_BOOST=1

Then I run make; make install && make clean, started it and did basic checks, and then tried to run innodb.innodb test:

openxs@ao756:~$ cd dbs/8.0/mysql-test/
openxs@ao756:~/dbs/8.0/mysql-test$ ./mtr innodb.innodb
Logging: ./mtr  innodb.innodb
2018-07-29T18:04:31.670158Z 0 [Warning] [MY-010139] [Server] Changed limits: max_open_files: 1024 (requested 8161)
2018-07-29T18:04:31.671031Z 0 [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 431 (requested 4000)
MySQL Version 8.0.12
Checking supported features...
 - SSL connections supported
Collecting tests...
Checking leftover processes...
Removing old var directory...
Creating var directory '/home/openxs/dbs/8.0/mysql-test/var'...
Installing system database...
Checking leftover processes...
Removing old var directory...
Creating var directory '/home/openxs/dbs/8.0/mysql-test/var'...
Installing system database...
Using parallel: 1

==============================================================================

TEST                                      RESULT   TIME (ms) or COMMENT
--------------------------------------------------------------------------

worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009
...
#93 0x000000000203da90 in pfs_spawn_thread (arg=0x3fdbca0) at pfs.cc:2836
#94 0x00007fad19722184 in start_thread (arg=0x7fad0c55c700) at pthread_create.c:312
#95 0x00007fad17ddb03d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

--------------------------------------------------------------------------
The servers were restarted 0 times
Spent 0.000 of 202 seconds executing testcases

Completed: Failed 1/1 tests, 0.00% were successful.

Failing test(s): innodb.innodb

The log files in var/log may give you some hint of what went wrong.

If you want to report this error, please read first the documentation
at http://dev.mysql.com/doc/mysql/en/mysql-test-suite.html

mysql-test-run: *** ERROR: there were failing test cases

In var/log/innodb.innodb/innodb.log I see:

...
INSERT INTO t1 VALUES ('old', 'somevalu'), ('other', 'anyvalue');
INSERT INTO t2 VALUES (10, 'old'), (20, 'other');
UPDATE t1 SET c1 = 'other' WHERE c1 = 'old';
ERROR 23000: Foreign key constraint for table 't1', record 'other-somevalu' would lead to a duplicate entry in table 't2', key 'c1'
DROP TABLE t2,t1;
call mtr.add_suppression("Cannot delete/update rows with cascading foreign key constraints that exceed max depth of 15. Please drop excessive foreign constraints and try again");
create table t1(
id int primary key,
pid int,
index(pid),
foreign key(pid) references t1(id) on delete cascade) engine=innodb;
insert into t1 values(0,0),(1,0),(2,1),(3,2),(4,3),(5,4),(6,5),(7,6),
(8,7),(9,8),(10,9),(11,10),(12,11),(13,12),(14,13),(15,14);
delete from t1 where id=0;
ERROR HY000: Foreign key cascade delete/update exceeds max depth of 15.
delete from t1 where id=15;

In the error log I see:

...
2018-07-29T18:05:27.806512Z 0 [System] [MY-010931] [Server] /home/openxs/dbs/8.0/bin/mysqld: ready for connections. Version: '8.0.12'  socket: '/home/openxs/dbs/8.0/mysql-test/var/tmp/mysqld.1.sock'  port: 13000  MySQL Community Server (GPL).
2018-07-29T18:07:09.393957Z 8 [ERROR] [MY-012799] [InnoDB] InnoDB: Cannot delete/update rows with cascading foreign key constraints that exceed max depth of 15. Please drop excessive foreign constraints and try again
18:07:09 UTC - mysqld got signal 11 ;

...
Thread pointer: 0x7facc801b270
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 7fad0c55bd80 thread_stack 0x46000
/home/openxs/dbs/8.0/bin/mysqld(my_print_stacktrace(unsigned char*, unsigned long)+0x2e) [0x1be0a3e]
/home/openxs/dbs/8.0/bin/mysqld(handle_fatal_signal+0x425) [0xd98875]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x10330) [0x7fad1972a330]
/home/openxs/dbs/8.0/bin/mysqld() [0x1def057]
/home/openxs/dbs/8.0/bin/mysqld(row_upd_step(que_thr_t*)+0x1f1) [0x1df05a1]
/home/openxs/dbs/8.0/bin/mysqld(row_update_cascade_for_mysql(que_thr_t*, upd_node_t*, dict_table_t*)+0x95) [0x1dc1b55]
/home/openxs/dbs/8.0/bin/mysqld(row_ins_check_foreign_constraint(unsigned long, dict_foreign_t*, dict_table_t*, dtuple_t*, que_thr_t*)+0x241a) [0x1db226a]
/home/openxs/dbs/8.0/bin/mysqld() [0x1de8c23]
/home/openxs/dbs/8.0/bin/mysqld() [0x1deea3f]
/home/openxs/dbs/8.0/bin/mysqld(row_upd_step(que_thr_t*)+0xe5) [0x1df0495]
/home/openxs/dbs/8.0/bin/mysqld(row_update_cascade_for_mysql(que_thr_t*, upd_node_t*, dict_table_t*)+0x95) [0x1dc1b55]
/home/openxs/dbs/8.0/bin/mysqld(row_ins_check_foreign_constraint(unsigned long, dict_foreign_t*, dict_table_t*, dtuple_t*, que_thr_t*)+0x241a) [0x1db226a]
/home/openxs/dbs/8.0/bin/mysqld() [0x1de8c23]
/home/openxs/dbs/8.0/bin/mysqld() [0x1deea3f]
/home/openxs/dbs/8.0/bin/mysqld(row_upd_step(que_thr_t*)+0xe5) [0x1df0495]
/home/openxs/dbs/8.0/bin/mysqld(row_update_cascade_for_mysql(que_thr_t*, upd_node_t*, dict_table_t*)+0x95) [0x1dc1b55]
/home/openxs/dbs/8.0/bin/mysqld(row_ins_check_foreign_constraint(unsigned long, dict_foreign_t*, dict_table_t*, dtuple_t*, que_thr_t*)+0x241a) [0x1db226a]
/home/openxs/dbs/8.0/bin/mysqld() [0x1de8c23]
...
/home/openxs/dbs/8.0/bin/mysqld(row_update_for_mysql(unsigned char const*, row_prebuilt_t*)+0x20a) [0x1dc887a]
/home/openxs/dbs/8.0/bin/mysqld(ha_innobase::delete_row(unsigned char const*)+0x11e) [0x1cb44fe]
/home/openxs/dbs/8.0/bin/mysqld(handler::ha_delete_row(unsigned char const*)+0x12b) [0xe9a86b]
/home/openxs/dbs/8.0/bin/mysqld(Sql_cmd_delete::delete_from_single_table(THD*)+0x1542) [0xc57722]
/home/openxs/dbs/8.0/bin/mysqld(Sql_cmd_dml::execute(THD*)+0x13f) [0xcd485f]
/home/openxs/dbs/8.0/bin/mysqld(mysql_execute_command(THD*, bool)+0x615) [0xc86bf5]
/home/openxs/dbs/8.0/bin/mysqld(mysql_parse(THD*, Parser_state*)+0x350) [0xc8be60]
/home/openxs/dbs/8.0/bin/mysqld(dispatch_command(THD*, COM_DATA const*, enum_server_command)+0x113a) [0xc8d17a]
/home/openxs/dbs/8.0/bin/mysqld(do_command(THD*)+0x1a8) [0xc8fb18]
/home/openxs/dbs/8.0/bin/mysqld() [0xd88948]
/home/openxs/dbs/8.0/bin/mysqld() [0xd88948]
/home/openxs/dbs/8.0/bin/mysqld() [0x203da90]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x8184) [0x7fad19722184]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7fad17ddb03d]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (7facc840f828): delete from t1 where id=0
Connection ID (thread ID): 8
Status: NOT_KILLED

The test case seems to be fresh:

openxs@ao756:~/dbs/8.0/mysql-test$ ls -l suite/innodb/t/innodb.test
-rw-rw-r-- 1 openxs openxs 81286 лип 29 12:52 suite/innodb/t/innodb.test

In any case, test from public test suite should never lead to crash.

How to repeat:
Do the following with mysql-server already cloned from GitHub (from fc -l output):

1959     cd git/mysql-server/
1960     git branch
1961     git pull
1962     rm CMakeCache.txt
1963     cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_CONFIG=mysql_release -DFEATURE_SET=community -DWITH_EMBEDDED_SERVER=OFF -DCMAKE_INSTALL_PREFIX=/home/openxs/dbs/8.0 -DWITH_BOOST=/home/openxs/boost -DDOWNLOAD_BOOST=1
...
1965     time make -j 2
...
1984     cd dbs/8.0/mysql-test/
1985     ./mtr --force --suite=innodb
1986     cd dbs/8.0/mysql-test/
1987     ./mtr innodb.innodb
1988     vi var/log/innodb.innodb/innodb.log
1989     vi var/log/mysqld.1.err
1990     ls -l suite/innodb/t/innodb.test
1991     fc -l

Suggested fix:
Do something for innodb.innodb test NOT to lead to crash. I assume that this is related to  cascade foreign key depth limit set back to 15, but there must not be a crash in any case.
[30 Jul 2018 5:32] MySQL Verification Team
Hello Valeriy,

Thank you for the report and feedback!
Verified as described.

regards,
Umesh
[30 Jul 2018 5:46] MySQL Verification Team
8.0.12 source build - affected

Attachment: 91823_8.0.12.results (application/octet-stream, text), 90.75 KiB.

[2 Aug 2018 10:49] Erlend Dahl
Posted by developer:
 
I can repeat this, but only if I go back to gcc 4.8.5 on OEL 7. With the default compiler (gcc 7.2.1) on OEL 7 the test passes, which explains why we haven't seen this internally.
[28 Oct 2018 22:02] Daniel Price
Posted by developer:
 
Fixed in 8.0.13.

Due to a GCC 8 bug, recursion in foreign key checks could exhaust
stack space.