[MDEV-19621] Server crashes in ha_innobase::commit_inplace_alter_table upon dropping virtual column Created: 2019-05-28  Updated: 2020-10-20  Resolved: 2020-10-15

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table, Storage Engine - InnoDB, Virtual Columns
Affects Version/s: 10.2, 10.3, 10.4, 10.5
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Thirunarayanan Balathandayuthapani
Resolution: Duplicate Votes: 0
Labels: None

Issue Links:
Duplicate
is duplicated by MDEV-19250 Alter table results in foreign key er... Closed
Relates
relates to MDEV-18321 Server crash or Failing assertion: 0 ... Closed

 Description   

Note: It can be a duplicate of anything. I've lost count of virtual column-related bugs, and the stack trace is non-specific.

--source include/have_innodb.inc
 
CREATE TABLE t1 (a INT, b INT, c INT AS (b), KEY(b)) ENGINE=InnoDB;
ALTER TABLE t1 ADD FOREIGN KEY (a) REFERENCES t1 (b);
ALTER TABLE t1 ADD KEY idx (a);
SET FOREIGN_KEY_CHECKS = OFF ;
ALTER TABLE t1 DROP KEY idx;
ALTER TABLE t1 DROP COLUMN c;
 
# Cleanup
DROP TABLE t1;

10.2 bff9b802

2019-05-28 16:57:09 140003140097792 [Warning] InnoDB: Load table `test`.`t1` failed, the table has missing foreign key indexes. Turn off 'foreign_key_checks' and try again.
 
#3  <signal handler called>
#4  0x000055cf7c901f5d in ha_innobase::commit_inplace_alter_table (this=0x7f54ac082c88, altered_table=0x7f54ac03cb40, ha_alter_info=0x7f55056e9c60, commit=true) at /data/src/10.2/storage/innobase/handler/handler0alter.cc:8677
#5  0x000055cf7c6bd0bb in handler::ha_commit_inplace_alter_table (this=0x7f54ac082c88, altered_table=0x7f54ac03cb40, ha_alter_info=0x7f55056e9c60, commit=true) at /data/src/10.2/sql/handler.cc:4325
#6  0x000055cf7c50975d in mysql_inplace_alter_table (thd=0x7f54ac000b00, table_list=0x7f54ac012330, table=0x7f54ac082080, altered_table=0x7f54ac03cb40, ha_alter_info=0x7f55056e9c60, inplace_supported=HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE, target_mdl_request=0x7f55056e9cf0, alter_ctx=0x7f55056ea2a0) at /data/src/10.2/sql/sql_table.cc:7388
#7  0x000055cf7c50f152 in mysql_alter_table (thd=0x7f54ac000b00, new_db=0x7f54ac012940 "test", new_name=0x0, create_info=0x7f55056eaeb0, table_list=0x7f54ac012330, alter_info=0x7f55056eae00, order_num=0, order=0x0, ignore=false) at /data/src/10.2/sql/sql_table.cc:9489
#8  0x000055cf7c589e7f in Sql_cmd_alter_table::execute (this=0x7f54ac012970, thd=0x7f54ac000b00) at /data/src/10.2/sql/sql_alter.cc:321
#9  0x000055cf7c440b96 in mysql_execute_command (thd=0x7f54ac000b00) at /data/src/10.2/sql/sql_parse.cc:6233
#10 0x000055cf7c445cba in mysql_parse (thd=0x7f54ac000b00, rawbuf=0x7f54ac012248 "ALTER TABLE t1 DROP COLUMN c", length=28, parser_state=0x7f55056ec250, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:8020
#11 0x000055cf7c43350e in dispatch_command (command=COM_QUERY, thd=0x7f54ac000b00, packet=0x7f54ac066eb1 "ALTER TABLE t1 DROP COLUMN c", packet_length=28, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1833
#12 0x000055cf7c431e62 in do_command (thd=0x7f54ac000b00) at /data/src/10.2/sql/sql_parse.cc:1386
#13 0x000055cf7c584b38 in do_handle_one_connection (connect=0x55cf7fae80f0) at /data/src/10.2/sql/sql_connect.cc:1335
#14 0x000055cf7c5848b8 in handle_one_connection (arg=0x55cf7fae80f0) at /data/src/10.2/sql/sql_connect.cc:1241
#15 0x00007f5509b054a4 in start_thread (arg=0x7f55056ed700) at pthread_create.c:456
#16 0x00007f550804dd0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97

All of debug, ASAN and non-debug builds fail with SEGV.
Not reproducible on 10.1.



 Comments   
Comment by Alice Sherepa [ 2020-06-25 ]

After fixing this bug, please check also the test case from MDEV-18321, MDEV-19250

--source include/have_innodb.inc
 
CREATE TABLE t1 (a INT, KEY(a), UNIQUE(a), FOREIGN KEY (a) REFERENCES t1 (a)) ENGINE=InnoDB;
ALTER TABLE t1 DROP INDEX a;
ALTER TABLE t1 ADD COLUMN v INT AS (a);
 
# Cleanup
DROP TABLE t1;

--source include/have_innodb.inc
 
CREATE TABLE a (id int NOT NULL, CONSTRAINT pk_a PRIMARY KEY (id)) engine=innodb;
CREATE TABLE b (id int NOT NULL, CONSTRAINT pk_b PRIMARY KEY (id)) engine=innodb;
 
CREATE TABLE src (a_id int NOT NULL, b_id int NOT NULL, 
	CONSTRAINT pk_src PRIMARY KEY (a_id), 
	CONSTRAINT fk_src_a FOREIGN KEY (a_id) REFERENCES a (id), 
    CONSTRAINT fk_src_b FOREIGN KEY (b_id) REFERENCES b (id) 
) engine=innodb;
 
CREATE TABLE REF ( a_id int NOT NULL, b_id int NOT NULL,
	CONSTRAINT fk_ref_a_b FOREIGN KEY (b_id, a_id) REFERENCES src (b_id,a_id)
) engine=innodb;
 
alter table src
 add constraint UQ_src_a unique (a_id), drop primary key,
 add column id int not null, add constraint PK_src primary key (id);
 
alter table src add column other int generated always as (1);

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