[MDEV-32204] Server crashes in get_schema_key_period_usage_record Created: 2023-09-19  Updated: 2023-09-25  Resolved: 2023-09-25

Status: Closed
Project: MariaDB Server
Component/s: Information Schema
Affects Version/s: N/A
Fix Version/s: 11.3.1

Type: Bug Priority: Critical
Reporter: Alice Sherepa Assignee: Nikita Malyavin
Resolution: Duplicate Votes: 0
Labels: tls

Issue Links:
Duplicate
duplicates MDEV-32205 Server crashes in get_schema_key_peri... In Testing
Problem/Incident
is caused by MDEV-22597 Add views for periods in information_... In Testing

 Description   

CREATE TABLE t (a date) engine=myisam;
CREATE TABLE  t1 (a int) ENGINE=MERGE UNION = (t) ;
 
SELECT 1 FROM information_schema.key_period_usage;

230919 18:29:28 [ERROR] mysqld got signal 11 ;
 
Server version: 11.3.0-MariaDB-debug-log source revision: b09e99ff759f66c29e3f67911ef4c7c0591c8a4e
 
sql/signal_handler.cc:241(handle_fatal_signal)[0x55d44e8a6546]
sigaction.c:0(__restore_rt)[0x7f0dd0cbd420]
sql/sql_show.cc:7730(get_schema_key_period_usage_record(THD*, TABLE_LIST*, TABLE*, bool, st_mysql_const_lex_string const*, st_mysql_const_lex_string const*))[0x55d44e1a3e12]
sql/sql_show.cc:4795(fill_schema_table_by_open(THD*, st_mem_root*, bool, TABLE*, st_schema_table*, st_mysql_const_lex_string*, st_mysql_const_lex_string*, Open_tables_backup*, bool))[0x55d44e17db5c]
sql/sql_show.cc:5473(get_all_tables(THD*, TABLE_LIST*, Item*))[0x55d44e18222f]
sql/sql_show.cc:9295(get_schema_tables_result(JOIN*, enum_schema_table_state))[0x55d44e1b8150]
sql/sql_select.cc:4897(JOIN::exec_inner())[0x55d44e070829]
sql/sql_select.cc:4718(JOIN::exec())[0x55d44e06e4c0]
sql/sql_select.cc:5249(mysql_select(THD*, TABLE_LIST*, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x55d44e072ccb]
sql/sql_select.cc:628(handle_select(THD*, LEX*, select_result*, unsigned long long))[0x55d44e0422aa]
sql/sql_parse.cc:6013(execute_sqlcom_select(THD*, TABLE_LIST*))[0x55d44df636a3]
sql/sql_parse.cc:3912(mysql_execute_command(THD*, bool))[0x55d44df53e16]
sql/sql_parse.cc:7734(mysql_parse(THD*, char*, unsigned int, Parser_state*))[0x55d44df6e702]
sql/sql_parse.cc:1895(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool))[0x55d44df46357]
sql/sql_parse.cc:1406(do_command(THD*, bool))[0x55d44df4309c]
sql/sql_connect.cc:1445(do_handle_one_connection(CONNECT*, bool))[0x55d44e423677]
sql/sql_connect.cc:1349(handle_one_connection)[0x55d44e422fd4]
perfschema/pfs.cc:2203(pfs_spawn_thread)[0x55d44f092a64]
nptl/pthread_create.c:478(start_thread)[0x7f0dd0cb1609]
 
Query (0x6290001092a8): SELECT 1 FROM information_schema.key_period_usage



 Comments   
Comment by Elena Stepanova [ 2023-09-19 ]

Note that if you run it in MTR, you don't need table creation at all, it will crash with the SELECT alone (as in MDEV-32205).
But the test case in the description fails even on the server with default settings, that is, with InnoDB enabled, unlike MDEV-32205.

Comment by Roel Van de Paar [ 2023-09-20 ]

Another testcase. Note optimized builds are affected also.

CREATE VIEW v1 AS SELECT 1;
CREATE VIEW v2 AS SELECT * FROM v1;
DROP VIEW v1;
SELECT * FROM information_schema.key_period_usage;
SELECT SLEEP(3);

Leads to:

preview-11.3-preview fd14f7c33f150aa93bb3eef15b672074548192d8 (Optimized)

11.3.0-opt>SELECT * FROM information_schema.key_period_usage;
ERROR 2026 (HY000): TLS/SSL error: The TLS connection was non-properly terminated.
11.3.0-opt>SELECT SLEEP(3);
ERROR 2006 (HY000): Server has gone away

preview-11.3-preview fd14f7c33f150aa93bb3eef15b672074548192d8 (Debug)

Core was generated by `/test/preview-11.3-preview_MDEV-28856_MD160923-mariadb-11.3.0-linux-x86_64-dbg/'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000055700c2d6ff4 in get_schema_key_period_usage_record (
    thd=0x150e80000d58, tables=0x150e80029cb0, schema_table=0x150e80021340, 
    res=true, db_name=0x150e80027378, table_name=0x150e800273a8)
    at /test/preview-11.3-preview_dbg/sql/sql_show.cc:7729
[Current thread is 1 (Thread 0x150ed00be640 (LWP 2483275))]
(gdb) bt
#0  0x000055700c2d6ff4 in get_schema_key_period_usage_record (thd=0x150e80000d58, tables=0x150e80029cb0, schema_table=0x150e80021340, res=true, db_name=0x150e80027378, table_name=0x150e800273a8) at /test/preview-11.3-preview_dbg/sql/sql_show.cc:7729
#1  0x000055700c2bd7c6 in fill_schema_table_by_open (thd=thd@entry=0x150e80000d58, mem_root=mem_root@entry=0x150ed00bac70, is_show_fields_or_keys=is_show_fields_or_keys@entry=false, table=table@entry=0x150e80021340, schema_table=schema_table@entry=0x55700d7a2100 <schema_tables+1344>, orig_db_name=orig_db_name@entry=0x150e80027378, orig_table_name=0x150e800273a8, open_tables_state_backup=0x150ed00bacb0, can_deadlock=false) at /test/preview-11.3-preview_dbg/sql/sql_show.cc:4794
#2  0x000055700c2e1335 in get_all_tables (thd=0x150e80000d58, tables=0x150e800192c8, cond=<optimized out>) at /test/preview-11.3-preview_dbg/sql/sql_show.cc:5472
#3  0x000055700c2e27fa in get_schema_tables_result (join=join@entry=0x150e8001a708, executed_place=executed_place@entry=PROCESSED_BY_JOIN_EXEC) at /test/preview-11.3-preview_dbg/sql/sql_show.cc:9294
#4  0x000055700c2b6538 in JOIN::exec_inner (this=this@entry=0x150e8001a708) at /test/preview-11.3-preview_dbg/sql/sql_select.cc:4898
#5  0x000055700c2b70a4 in JOIN::exec (this=this@entry=0x150e8001a708) at /test/preview-11.3-preview_dbg/sql/sql_select.cc:4718
#6  0x000055700c2b4e13 in mysql_select (thd=thd@entry=0x150e80000d58, tables=0x150e800192c8, fields=@0x150e80018f28: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x150e80019248, last = 0x150e8001b8e0, elements = 7}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2701396736, result=0x150e8001a6e0, unit=0x150e800051a8, select_lex=0x150e80018c70) at /test/preview-11.3-preview_dbg/sql/sql_select.cc:5249
#7  0x000055700c2b563c in handle_select (thd=thd@entry=0x150e80000d58, lex=lex@entry=0x150e800050c8, result=result@entry=0x150e8001a6e0, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/preview-11.3-preview_dbg/sql/sql_select.cc:628
#8  0x000055700c215f8a in execute_sqlcom_select (thd=thd@entry=0x150e80000d58, all_tables=0x150e800192c8) at /test/preview-11.3-preview_dbg/sql/sql_parse.cc:6012
#9  0x000055700c221f7c in mysql_execute_command (thd=thd@entry=0x150e80000d58, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/preview-11.3-preview_dbg/sql/sql_parse.cc:3911
#10 0x000055700c228477 in mysql_parse (thd=thd@entry=0x150e80000d58, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x150ed00bd1e0) at /test/preview-11.3-preview_dbg/sql/sql_parse.cc:7734
#11 0x000055700c22a7ed in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x150e80000d58, packet=packet@entry=0x150e8000b119 "SELECT * FROM information_schema.key_period_usage", packet_length=packet_length@entry=49, blocking=blocking@entry=true) at /test/preview-11.3-preview_dbg/sql/sql_class.h:251
#12 0x000055700c22c90d in do_command (thd=0x150e80000d58, blocking=blocking@entry=true) at /test/preview-11.3-preview_dbg/sql/sql_parse.cc:1406
#13 0x000055700c38c1f7 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55700f871318, put_in_cache=put_in_cache@entry=true) at /test/preview-11.3-preview_dbg/sql/sql_connect.cc:1445
#14 0x000055700c38c4ec in handle_one_connection (arg=arg@entry=0x55700f871318) at /test/preview-11.3-preview_dbg/sql/sql_connect.cc:1347
#15 0x000055700c7cef02 in pfs_spawn_thread (arg=0x55700f7f18f8) at /test/preview-11.3-preview_dbg/storage/perfschema/pfs.cc:2201
#16 0x0000150ee7c94b43 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#17 0x0000150ee7d26a00 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

preview-11.3-preview fd14f7c33f150aa93bb3eef15b672074548192d8 (Optimized)

Core was generated by `/test/preview-11.3-preview_MDEV-28856_MD160923-mariadb-11.3.0-linux-x86_64-opt/'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00005636d0cabb67 in get_schema_key_period_usage_record (
    thd=0x145e4c000c68, tables=0x145e4c1e6e20, schema_table=0x145e4c01c200, 
    res=true, db_name=0x145e4c0216c8, table_name=0x145e4c207550)
    at /test/preview-11.3-preview_opt/sql/sql_show.cc:7729
[Current thread is 1 (Thread 0x145eec120640 (LWP 2541551))]
(gdb) bt
#0  0x00005636d0cabb67 in get_schema_key_period_usage_record (thd=0x145e4c000c68, tables=0x145e4c1e6e20, schema_table=0x145e4c01c200, res=true, db_name=0x145e4c0216c8, table_name=0x145e4c207550) at /test/preview-11.3-preview_opt/sql/sql_show.cc:7729
#1  0x00005636d0c9c2b6 in fill_schema_table_by_open (thd=0x145e4c000c68, mem_root=<optimized out>, is_show_fields_or_keys=<optimized out>, table=0x145e4c01c200, schema_table=0x5636d1e71da0 <schema_tables+1344>, orig_db_name=0x145e4c0216c8, orig_table_name=0x145e4c207550, open_tables_state_backup=0x145eec11c470, can_deadlock=false) at /test/preview-11.3-preview_opt/sql/sql_show.cc:4794
#2  0x00005636d0cb4416 in get_all_tables (thd=0x145e4c000c68, tables=<optimized out>, cond=<optimized out>) at /test/preview-11.3-preview_opt/sql/sql_show.cc:5472
#3  0x00005636d0cb5f9e in get_schema_tables_result (join=join@entry=0x145e4c017d18, executed_place=executed_place@entry=PROCESSED_BY_JOIN_EXEC) at /test/preview-11.3-preview_opt/sql/sql_show.cc:9294
#4  0x00005636d0c97f57 in JOIN::exec_inner (this=0x145e4c017d18) at /test/preview-11.3-preview_opt/sql/sql_select.cc:4898
#5  0x00005636d0c9881e in JOIN::exec (this=this@entry=0x145e4c017d18) at /test/preview-11.3-preview_opt/sql/sql_select.cc:4718
#6  0x00005636d0c9678c in mysql_select (thd=0x145e4c000c68, tables=0x145e4c0168d8, fields=<optimized out>, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=<optimized out>, result=0x145e4c017cf0, unit=0x145e4c004ef8, select_lex=0x145e4c016280) at /test/preview-11.3-preview_opt/sql/sql_select.cc:5249
#7  0x00005636d0c96f84 in handle_select (thd=thd@entry=0x145e4c000c68, lex=lex@entry=0x145e4c004e18, result=result@entry=0x145e4c017cf0, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/preview-11.3-preview_opt/sql/sql_select.cc:628
#8  0x00005636d0c0ad75 in execute_sqlcom_select (thd=0x145e4c000c68, all_tables=0x145e4c0168d8) at /test/preview-11.3-preview_opt/sql/sql_parse.cc:6012
#9  0x00005636d0c19e82 in mysql_execute_command (thd=0x145e4c000c68, is_called_from_prepared_stmt=<optimized out>) at /test/preview-11.3-preview_opt/sql/sql_parse.cc:3911
#10 0x00005636d0c1b256 in mysql_parse (thd=0x145e4c000c68, rawbuf=<optimized out>, length=<optimized out>, parser_state=<optimized out>) at /test/preview-11.3-preview_opt/sql/sql_parse.cc:7734
#11 0x00005636d0c1d9ed in dispatch_command (command=COM_QUERY, thd=0x145e4c000c68, packet=<optimized out>, packet_length=<optimized out>, blocking=<optimized out>) at /test/preview-11.3-preview_opt/sql/sql_parse.cc:1990
#12 0x00005636d0c1f790 in do_command (thd=0x145e4c000c68, blocking=blocking@entry=true) at /test/preview-11.3-preview_opt/sql/sql_parse.cc:1406
#13 0x00005636d0d47e9f in do_handle_one_connection (connect=<optimized out>, put_in_cache=true) at /test/preview-11.3-preview_opt/sql/sql_connect.cc:1445
#14 0x00005636d0d481ed in handle_one_connection (arg=arg@entry=0x5636d4c15488) at /test/preview-11.3-preview_opt/sql/sql_connect.cc:1347
#15 0x00005636d10f2631 in pfs_spawn_thread (arg=0x5636d4bbe108) at /test/preview-11.3-preview_opt/storage/perfschema/pfs.cc:2201
#16 0x0000145eed494b43 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#17 0x0000145eed526a00 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

Comment by Roel Van de Paar [ 2023-09-20 ]

There is another oddity in regards this error:

preview-11.3-preview fd14f7c33f150aa93bb3eef15b672074548192d8 (Debug)

ERROR 2026 (HY000): TLS/SSL error: The TLS connection was non-properly terminated.

It is shown in preview-11.3-preview every time the server receives a crashing statement (i.e. any crashing testcase it looks like). Random example using a testcase from another bug:

preview-11.3-preview fd14f7c33f150aa93bb3eef15b672074548192d8 (Debug)

ERROR 2026 (HY000) at line 3 in file: 'MDEV-25593.sql': TLS/SSL error: The TLS connection was non-properly terminated.
ERROR 2006 (HY000) at line 5 in file: 'MDEV-25593.sql': Server has gone away
No connection. Trying to reconnect...

Also, in various cases it is shown instead of 'Server has gone away':

preview-11.3-preview fd14f7c33f150aa93bb3eef15b672074548192d8 (Debug)

11.3.0-dbg>DELETE FROM t1 USING v1, t1 WHERE v1.a=t2.a;  # non-relevant query, just a crashing example
ERROR 2026 (HY000): TLS/SSL error: The TLS connection was non-properly terminated.
11.3.0-dbg>exit

Versus regular 11.3:

11.3.0 8ad1e26b1bafa4ed9928306efc10c047f2274108 (Debug)

11.3.0-dbg>DELETE FROM t1 USING v1, t1 WHERE v1.a=t2.a;
ERROR 2013 (HY000): Lost connection to server during query
11.3.0-dbg>exit

Comment by Sergei Golubchik [ 2023-09-20 ]

SSL errors are normal, they were here before if SSL was enabled. It typically wasn't, and in 11.3 preview it is enabled by default.

Comment by Nikita Malyavin [ 2023-09-25 ]

Thank you for your findings, alice and Roel! I have included your tests in the MDEV-32205 patch.

Generated at Thu Feb 08 10:29:37 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.