[MDEV-13639] Server crashes in prepare_inplace_alter_table_dict upon altering a table with discarded tablespace Created: 2017-08-24  Updated: 2018-06-18  Resolved: 2018-06-18

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table, Storage Engine - InnoDB
Affects Version/s: 10.1.23, 10.2.5
Fix Version/s: 10.1.29, 10.2.11, 10.3.3

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates MDEV-14219 Allow online table rebuild when encry... Closed
Problem/Incident
is caused by MDEV-11581 Mariadb starts innodb encryption thre... Closed
is caused by MDEV-11738 Mariadb uses 100% of several of my 8 ... Closed

 Description   

--source include/have_innodb.inc
CREATE TABLE t1 (a SERIAL) ENGINE = InnoDB;
ALTER TABLE t1 DISCARD TABLESPACE;
ALTER TABLE t1 ENGINE InnoDB;

10.1 06106c01481

#3  <signal handler called>
#4  0x00007f23f331df74 in prepare_inplace_alter_table_dict (ha_alter_info=0x7f23fc304b00, altered_table=0x7f23e3d79070, old_table=0x7f23e3c81c70, table_name=0x7f23e3c68f5d "t1", flags=1, flags2=80, fts_doc_id_col=18446744073709551615, add_fts_doc_id=false, add_fts_doc_id_idx=false) at /data/src/10.1/storage/innobase/handler/handler0alter.cc:2899
#5  0x00007f23f3321f74 in ha_innodb::prepare_inplace_alter_table (this=0x7f23e3cb0888, altered_table=0x7f23e3d79070, ha_alter_info=0x7f23fc304b00) at /data/src/10.1/storage/innobase/handler/handler0alter.cc:4163
#6  0x000055cbd92f05ff in handler::ha_prepare_inplace_alter_table (this=0x7f23e3cb0888, altered_table=0x7f23e3d79070, ha_alter_info=0x7f23fc304b00) at /data/src/10.1/sql/handler.cc:4170
#7  0x000055cbd916f560 in mysql_inplace_alter_table (thd=0x7f23f07c7070, table_list=0x7f23e3cfa170, table=0x7f23e3c81c70, altered_table=0x7f23e3d79070, ha_alter_info=0x7f23fc304b00, inplace_supported=HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE, target_mdl_request=0x7f23fc304b70, alter_ctx=0x7f23fc305710) at /data/src/10.1/sql/sql_table.cc:7128
#8  0x000055cbd9173f45 in mysql_alter_table (thd=0x7f23f07c7070, new_db=0x7f23e3cfa760 "test", new_name=0x0, create_info=0x7f23fc306300, table_list=0x7f23e3cfa170, alter_info=0x7f23fc306270, order_num=0, order=0x0, ignore=false) at /data/src/10.1/sql/sql_table.cc:8973
#9  0x000055cbd91e4a0f in Sql_cmd_alter_table::execute (this=0x7f23e3cfa770, thd=0x7f23f07c7070) at /data/src/10.1/sql/sql_alter.cc:325
#10 0x000055cbd90b5c7a in mysql_execute_command (thd=0x7f23f07c7070) at /data/src/10.1/sql/sql_parse.cc:5699
#11 0x000055cbd90b9f2b in mysql_parse (thd=0x7f23f07c7070, rawbuf=0x7f23e3cfa088 "ALTER TABLE t1 ENGINE InnoDB", length=28, parser_state=0x7f23fc3075e0) at /data/src/10.1/sql/sql_parse.cc:7344
#12 0x000055cbd90a8e8a in dispatch_command (command=COM_QUERY, thd=0x7f23f07c7070, packet=0x7f23f2719071 "ALTER TABLE t1 ENGINE InnoDB", packet_length=28) at /data/src/10.1/sql/sql_parse.cc:1484
#13 0x000055cbd90a7c27 in do_command (thd=0x7f23f07c7070) at /data/src/10.1/sql/sql_parse.cc:1106
#14 0x000055cbd91dffa1 in do_handle_one_connection (thd_arg=0x7f23f07c7070) at /data/src/10.1/sql/sql_connect.cc:1349
#15 0x000055cbd91dfd05 in handle_one_connection (arg=0x7f23f07c7070) at /data/src/10.1/sql/sql_connect.cc:1261
#16 0x000055cbd9597cf2 in pfs_spawn_thread (arg=0x7f23f26e2970) at /data/src/10.1/storage/perfschema/pfs.cc:1860
#17 0x00007f23fbf98494 in start_thread (arg=0x7f23fc308b00) at pthread_create.c:333
#18 0x00007f23fa0e393f in clone () from /lib/x86_64-linux-gnu/libc.so.6

The crash was introduced by this commit:

commit 50eb40a2a8aa3af6cc271f6028f4d6d74301d030
Author: Jan Lindström <jan.lindstrom@mariadb.com>
Date:   Tue Mar 14 12:56:01 2017 +0200
 
    MDEV-11738: Mariadb uses 100% of several of my 8 cpus doing nothing
    
    MDEV-11581: Mariadb starts InnoDB encryption threads
    when key has not changed or data scrubbing turned off



 Comments   
Comment by Elena Stepanova [ 2017-08-24 ]

marko FYI

Comment by Marko Mäkelä [ 2018-06-18 ]

I fixed this bug while cleaning up the code as part of
MDEV-14219 Allow online table rebuild when encryption or compression parameters change

I can repeat this with the parent of the MDEV-14219 fix. With that fix (and any revision up to the latest 10.1), the server will not crash, but will report some warnings and errors instead:

10.1 f7b1b2bc5d6e1f923aca0ee8c5232cf095075c7b

CREATE TABLE t1 (a SERIAL) ENGINE = InnoDB;
ALTER TABLE t1 DISCARD TABLESPACE;
ALTER TABLE t1 ENGINE InnoDB;
Warnings:
Warning	1814	Tablespace has been discarded for table 't1'
DROP TABLE t1;
innodb.mdev13639 'innodb_plugin'         [ fail ]  Found warnings/errors in server log file!
        Test ended at 2018-06-18 22:27:07
line
2018-06-18 22:27:07 140449296407296 [Warning] InnoDB: Trying to access missing tablespace 4.
2018-06-18 22:27:07 140449296407296 [ERROR] InnoDB: Cannot delete tablespace 4 because it is not found in the tablespace memory cache.

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