Bug #99421 Crash in mysql server, Assertion failure: dict0dict.cc
Submitted: 3 May 2020 3:58 Modified: 27 Jan 2021 22:10
Reporter: Yongheng Chen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DDL Severity:S1 (Critical)
Version:8.0.20(master branch) OS:Any
Assigned to: CPU Architecture:Any

[3 May 2020 3:58] Yongheng Chen
Description:
Another assertion crash in mysql server.

Stack dump:
---
2020-05-02T20:02:19.825601Z 0 [System] [MY-010116] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.20-debug-asan) starting as process 60
2020-05-02T20:02:19.909786Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-05-02T20:02:21.394257Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-05-02T20:02:23.562560Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/tmp/mysqlx.sock' bind-address: '::' port: 33060
2020-05-02T20:02:25.162341Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-05-02T20:02:25.475736Z 0 [System] [MY-010931] [Server] /usr/local/mysql/bin/mysqld: ready for connections. Version: '8.0.20-debug-asan'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution.
2020-05-02T20:02:49.935742Z 0 [System] [MY-010116] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.20-debug-asan) starting as process 193
2020-05-02T20:02:49.979845Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-05-02T20:02:51.353323Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-05-02T20:02:53.572056Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/tmp/mysqlx.sock' bind-address: '::' port: 33060
2020-05-02T20:02:53.844342Z 0 [System] [MY-010229] [Server] Starting XA crash recovery...
2020-05-02T20:02:53.854280Z 0 [System] [MY-010232] [Server] XA crash recovery finished.
2020-05-02T20:02:54.002664Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-05-02T20:02:54.311876Z 0 [System] [MY-010931] [Server] /usr/local/mysql/bin/mysqld: ready for connections. Version: '8.0.20-debug-asan'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution.
2020-05-03T03:11:24.634201Z 180791 [ERROR] [MY-013183] [InnoDB] Assertion failure: dict0dict.cc:657:col_nr < static_cast<ulint>(table->n_t_def) thread 140136208946944
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/8.0/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
03:11:24 UTC - mysqld got signal 6 ;
Most likely, you have hit a bug, but this error can also be caused by malfunctioning hardware.
Thread pointer: 0x6270005be100
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 = 7f7400f44bc0 thread_stack 0x46000
/usr/local/mysql/bin/mysqld() [0x2acc291]
/usr/local/mysql/bin/mysqld(my_print_stacktrace(unsigned char const*, unsigned long)+0x10d) [0x7fa290d]
/usr/local/mysql/bin/mysqld(handle_fatal_signal+0x458) [0x3850f48]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12890) [0x7f7433318890]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7) [0x7f7431454e97]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x141) [0x7f7431456801]
/usr/local/mysql/bin/mysqld(ut_dbg_assertion_failed(char const*, char const*, unsigned long)+0x5d1) [0x8fa33d1]
/usr/local/mysql/bin/mysqld() [0x93d140e]
/usr/local/mysql/bin/mysqld(dict_table_get_v_col_name_mysql(dict_table_t const*, unsigned long)+0x4d) [0x93d0e2d]
/usr/local/mysql/bin/mysqld(dict_index_add_col(dict_index_t*, dict_table_t const*, dict_col_t*, unsigned long, bool)+0x284) [0x8fb9494]
/usr/local/mysql/bin/mysqld() [0x941cf0c]
/usr/local/mysql/bin/mysqld() [0x93f12a3]
/usr/local/mysql/bin/mysqld(dict_index_add_to_cache_w_vcol(dict_table_t*, dict_index_t*, dict_add_v_col_t const*, unsigned int, unsigned long)+0x677) [0x93e9e77]
/usr/local/mysql/bin/mysqld(row_merge_create_index(trx_t*, dict_table_t*, index_def_t const*, dict_add_v_col_t const*)+0x8ce) [0x8b3123e]
/usr/local/mysql/bin/mysqld() [0x85e71c7]
/usr/local/mysql/bin/mysqld(bool ha_innobase::prepare_inplace_alter_table_impl<dd::Table>(TABLE*, Alter_inplace_info*, dd::Table const*, dd::Table*)+0x7b28) [0x8635fc8]
/usr/local/mysql/bin/mysqld(ha_innobase::prepare_inplace_alter_table(TABLE*, Alter_inplace_info*, dd::Table const*, dd::Table*)+0x60f) [0x85a586f]
/usr/local/mysql/bin/mysqld() [0x34a5c35]
/usr/local/mysql/bin/mysqld(mysql_alter_table(THD*, char const*, char const*, HA_CREATE_INFO*, TABLE_LIST*, Alter_info*)+0x115b2) [0x347baf2]
/usr/local/mysql/bin/mysqld(Sql_cmd_create_or_drop_index_base::execute(THD*)+0x59e) [0x48728ae]
/usr/local/mysql/bin/mysqld(mysql_execute_command(THD*, bool)+0x4418) [0x3161788]
/usr/local/mysql/bin/mysqld(mysql_parse(THD*, Parser_state*)+0x19bc) [0x3156fdc]
/usr/local/mysql/bin/mysqld(dispatch_command(THD*, COM_DATA const*, enum_server_command)+0x7a9d) [0x314fa0d]
/usr/local/mysql/bin/mysqld(do_command(THD*)+0xda0) [0x31538b0]
/usr/local/mysql/bin/mysqld() [0x38062f5]
/usr/local/mysql/bin/mysqld() [0x9cb3391]
/usr/local/mysql/bin/mysqld() [0x2b16c6f]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76db) [0x7f743330d6db]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f) [0x7f743153788f]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (6120000aac9e): CREATE INDEX v2 ON v0 ( ( v1 = 127 ) , ( v1 + v1 ) , v1 , ( v1 + - -1 ) , ( v1 > 26 ) )
Connection ID (thread ID): 180791
Status: NOT_KILLED
---

How to repeat:
POC:
---
CREATE TABLE v0 ( v1 INT ) ;
INSERT INTO v0 ( v1 ) VALUES ( 44 ) ;
UPDATE v0 SET v1 = 21 WHERE 62 > -128 = ( NOT ( v1 IS NULL ) ) ;
INSERT INTO v0 ( v1 ) VALUES ( 0 ) , ( 82 ) ;
CREATE INDEX v2 ON v0 ( ( v1 = 127 ) , ( v1 + v1 ) , v1 , ( v1 + - -1 ) , ( v1 > 26 ) ) ;
---
[3 May 2020 7:01] MySQL Verification Team
Thanks for the report.  Verified on 8.0.19-debug and 8.0.20-debug.
[27 Jan 2021 22:10] Daniel Price
Posted by developer:
 
Fixed as of the upcoming 8.0.24 release, and here's the proposed changelog entry from the documentation team:

Creating an index on virtual columns raised an invalid debug assertion
failure.