[MDEV-32205] Server crashes in get_schema_key_period_usage_record on server without InnoDB Created: 2023-09-19  Updated: 2024-01-15

Status: In Testing
Project: MariaDB Server
Component/s: Information Schema
Affects Version/s: N/A
Fix Version/s: 11.4

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Nikita Malyavin
Resolution: Unresolved Votes: 0
Labels: None

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

 Description   

In MTR the one-line test can be run normally (as MTR already runs without InnoDB by default); upon using the client, start the server with --default-storage-engine=MyISAM --skip-innodb

SELECT * FROM information_schema.KEY_PERIOD_USAGE;

11.3 e6f224533a56e209930cdb10bf19a475d1cd4fd6

#3  <signal handler called>
#4  get_schema_key_period_usage_record (thd=0x7f24a4000dc8, tables=0x7f24a4208360, schema_table=0x7f24a4228750, res=true, db_name=0x7f24a41184d8, table_name=0x7f24a411aa60) at /data/src/preview-11.3-MDEV-22597-period/sql/sql_show.cc:7729
#5  0x00005643574a58b3 in fill_schema_table_by_open (thd=0x7f24a4000dc8, mem_root=0x7f24b6139830, is_show_fields_or_keys=false, table=0x7f24a4228750, schema_table=0x564359981d20 <schema_tables+1344>, orig_db_name=0x7f24a41184d8, orig_table_name=0x7f24a411aa60, open_tables_state_backup=0x7f24b6139870, can_deadlock=false) at /data/src/preview-11.3-MDEV-22597-period/sql/sql_show.cc:4794
#6  0x00005643574a8ed3 in get_all_tables (thd=0x7f24a4000dc8, tables=0x7f24a4015f48, cond=0x0) at /data/src/preview-11.3-MDEV-22597-period/sql/sql_show.cc:5472
#7  0x00005643574ca4c6 in get_schema_tables_result (join=0x7f24a4017388, executed_place=PROCESSED_BY_JOIN_EXEC) at /data/src/preview-11.3-MDEV-22597-period/sql/sql_show.cc:9294
#8  0x00005643573e4b1d in JOIN::exec_inner (this=0x7f24a4017388) at /data/src/preview-11.3-MDEV-22597-period/sql/sql_select.cc:4898
#9  0x00005643573e33c7 in JOIN::exec (this=0x7f24a4017388) at /data/src/preview-11.3-MDEV-22597-period/sql/sql_select.cc:4718
#10 0x00005643573e6721 in mysql_select (thd=0x7f24a4000dc8, tables=0x7f24a4015f48, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2701396736, result=0x7f24a4017360, unit=0x7f24a4005218, select_lex=0x7f24a40158f0) at /data/src/preview-11.3-MDEV-22597-period/sql/sql_select.cc:5249
#11 0x00005643573c595b in handle_select (thd=0x7f24a4000dc8, lex=0x7f24a4005138, result=0x7f24a4017360, setup_tables_done_option=0) at /data/src/preview-11.3-MDEV-22597-period/sql/sql_select.cc:628
#12 0x0000564357316a3f in execute_sqlcom_select (thd=0x7f24a4000dc8, all_tables=0x7f24a4015f48) at /data/src/preview-11.3-MDEV-22597-period/sql/sql_parse.cc:6012
#13 0x00005643573050b7 in mysql_execute_command (thd=0x7f24a4000dc8, is_called_from_prepared_stmt=false) at /data/src/preview-11.3-MDEV-22597-period/sql/sql_parse.cc:3911
#14 0x000056435731ffd9 in mysql_parse (thd=0x7f24a4000dc8, rawbuf=0x7f24a4015830 "SELECT * FROM information_schema.KEY_PERIOD_USAGE", length=49, parser_state=0x7f24b613b330) at /data/src/preview-11.3-MDEV-22597-period/sql/sql_parse.cc:7734
#15 0x00005643572f8344 in dispatch_command (command=COM_QUERY, thd=0x7f24a4000dc8, packet=0x7f24a400bc19 "SELECT * FROM information_schema.KEY_PERIOD_USAGE", packet_length=49, blocking=true) at /data/src/preview-11.3-MDEV-22597-period/sql/sql_parse.cc:1893
#16 0x00005643572f5465 in do_command (thd=0x7f24a4000dc8, blocking=true) at /data/src/preview-11.3-MDEV-22597-period/sql/sql_parse.cc:1406
#17 0x000056435769414b in do_handle_one_connection (connect=0x56435c575788, put_in_cache=true) at /data/src/preview-11.3-MDEV-22597-period/sql/sql_connect.cc:1445
#18 0x0000564357693b76 in handle_one_connection (arg=0x56435c5b59a8) at /data/src/preview-11.3-MDEV-22597-period/sql/sql_connect.cc:1347
#19 0x0000564357ff55af in pfs_spawn_thread (arg=0x56435c5752f8) at /data/src/preview-11.3-MDEV-22597-period/storage/perfschema/pfs.cc:2201
#20 0x00007f24bb6a7fd4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#21 0x00007f24bb7285bc in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81



 Comments   
Comment by Nikita Malyavin [ 2023-09-21 ]

A devil jerked my hand to make a refactoring, that should prevent such kind of errors in future.

Please review the following commits:

0929cbbb MDEV-32205 crash in get_schema_key_period_usage_record without InnoDB
0e709489 Add Statement::sql_command_flags() function.

Comment by Sergei Golubchik [ 2023-09-22 ]

pretty good. 0e709489 is ok. questions about 0929cbbb:

  • could you take a quick look in if there were other I_S tables that didn't handle the open error? If yes — add tests for them too.
  • why do you get "Unknown storage engine 'InnoDB'" ? What does the test has to do with InnoDB?
Comment by Nikita Malyavin [ 2023-09-25 ]

serg,
> why do you get "Unknown storage engine 'InnoDB'" ? What does the test has to do with InnoDB?

get_al_tables traverses all the tables and opens it. If the server was started without innodb, the innodb-backed table will not open, and an unknown storage engine error will be set in stmt_da.

Comment by Sergei Golubchik [ 2023-09-25 ]

ok, please add something like

select table_schema, table_name, storage_engine from information_schema.tables

to your test at the beginning to show that there is an InnoDB table somewhere

Comment by Nikita Malyavin [ 2023-09-25 ]

> could you take a quick look in if there were other I_S tables that didn't handle the open error? If yes — add tests for them too.

I have run select on all the tables in the schema_tables array – no problems.
Also I forgot to remove an error check from GEOMETRY_COLUMNS, which also uses get_all_tables (the new commit is 908ca080e).

The rest of the plugin doesn't make sense to check, since they use different approaches for filling the data.

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