Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
10.0(EOL), 10.1(EOL), 10.2(EOL), 10.3(EOL)
-
10.2.14
Description
--source include/have_innodb.inc
|
--source include/have_partition.inc
|
|
CREATE TABLE t1 (a INT, b INT) ENGINE=InnoDB PARTITION BY HASH(a) PARTITIONS 2; |
XA START 'xid'; |
INSERT INTO t1 VALUES (1,10); |
--error ER_XAER_RMFAIL
|
CREATE DATABASE IF NOT EXISTS db; |
|
--connect (con1,localhost,root,,test)
|
SET innodb_lock_wait_timeout= 1, lock_wait_timeout= 2; |
ALTER TABLE t1 DROP COLUMN b; |
|
# Cleanup
|
--disconnect con1
|
--connection default
|
XA END 'xid'; |
XA ROLLBACK 'xid'; |
DROP TABLE t1; |
10.0 9216a4f69f11 |
mysqld: /data/src/10.0/storage/innobase/handler/handler0alter.cc:4366: bool rollback_inplace_alter_table(Alter_inplace_info*, const TABLE*, row_prebuilt_t*): Assertion `!clust_index->online_log' failed.
|
180220 14:28:33 [ERROR] mysqld got signal 6 ;
|
|
#7 0x00007fc189c50ee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
|
#8 0x00007fc18276c7d8 in rollback_inplace_alter_table (ha_alter_info=0x7fc18bcc7260, table=0x7fc17589e470, prebuilt=0x7fc175a12078) at /data/src/10.0/storage/innobase/handler/handler0alter.cc:4366
|
#9 0x00007fc182769f39 in ha_innodb::commit_inplace_alter_table (this=0x7fc175880088, altered_table=0x7fc175ce4070, ha_alter_info=0x7fc18bcc7260, commit=false) at /data/src/10.0/storage/innobase/handler/handler0alter.cc:5640
|
#10 0x0000000000842aad in handler::ha_commit_inplace_alter_table (this=0x7fc175880088, altered_table=0x7fc175ce4070, ha_alter_info=0x7fc18bcc7260, commit=false) at /data/src/10.0/sql/handler.cc:4226
|
#11 0x0000000000df87ed in ha_partition::commit_inplace_alter_table (this=0x7fc17587f088, altered_table=0x7fc175ce4070, ha_alter_info=0x7fc18bcc7260, commit=false) at /data/src/10.0/sql/ha_partition.cc:8405
|
#12 0x0000000000842aad in handler::ha_commit_inplace_alter_table (this=0x7fc17587f088, altered_table=0x7fc175ce4070, ha_alter_info=0x7fc18bcc7260, commit=false) at /data/src/10.0/sql/handler.cc:4226
|
#13 0x0000000000701565 in mysql_inplace_alter_table (thd=0x7fc17e36f070, table_list=0x7fc175c22170, table=0x7fc17589e470, altered_table=0x7fc175ce4070, ha_alter_info=0x7fc18bcc7260, inplace_supported=HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE, target_mdl_request=0x7fc18bcc6cb0, alter_ctx=0x7fc18bcc7840) at /data/src/10.0/sql/sql_table.cc:7232
|
#14 0x0000000000705852 in mysql_alter_table (thd=0x7fc17e36f070, new_db=0x7fc175c22750 "test", new_name=0x0, create_info=0x7fc18bcc84e0, table_list=0x7fc175c22170, alter_info=0x7fc18bcc8450, order_num=0, order=0x0, ignore=false) at /data/src/10.0/sql/sql_table.cc:8949
|
#15 0x000000000076e2b1 in Sql_cmd_alter_table::execute (this=0x7fc175c22780, thd=0x7fc17e36f070) at /data/src/10.0/sql/sql_alter.cc:312
|
#16 0x0000000000654607 in mysql_execute_command (thd=0x7fc17e36f070) at /data/src/10.0/sql/sql_parse.cc:5114
|
#17 0x0000000000657a3e in mysql_parse (thd=0x7fc17e36f070, rawbuf=0x7fc175c22088 "ALTER TABLE t1 DROP COLUMN b", length=28, parser_state=0x7fc18bcc9640) at /data/src/10.0/sql/sql_parse.cc:6569
|
#18 0x000000000064a57d in dispatch_command (command=COM_QUERY, thd=0x7fc17e36f070, packet=0x7fc17e375071 "ALTER TABLE t1 DROP COLUMN b", packet_length=28) at /data/src/10.0/sql/sql_parse.cc:1296
|
#19 0x000000000064987d in do_command (thd=0x7fc17e36f070) at /data/src/10.0/sql/sql_parse.cc:999
|
#20 0x0000000000769a04 in do_handle_one_connection (thd_arg=0x7fc17e36f070) at /data/src/10.0/sql/sql_connect.cc:1377
|
#21 0x0000000000769776 in handle_one_connection (arg=0x7fc17e36f070) at /data/src/10.0/sql/sql_connect.cc:1292
|
#22 0x0000000000aca0fc in pfs_spawn_thread (arg=0x7fc17e319b70) at /data/src/10.0/storage/perfschema/pfs.cc:1861
|
#23 0x00007fc18b954494 in start_thread (arg=0x7fc18bcca700) at pthread_create.c:333
|
#24 0x00007fc189d0d93f in clone () from /lib/x86_64-linux-gnu/libc.so.6
|
Reproducible on all of 10.x. Not reproducible on MariaDB 5.5, MySQL 5.6.39, 5.7.21.
Attachments
Issue Links
- is duplicated by
-
MDEV-15490 XA: ASAN heap-use-after-free or valgrind Invalid write in trx_update_mod_tables_timestamp
-
- Closed
-
- relates to
-
MDEV-15518 XA: Server crash or ASAN heap-use-after-free in ha_innobase::delete_table
-
- Closed
-
-
MDEV-15533 Assertion `log->blobs' failed in row_log_table_apply_update
-
- Closed
-
-
MDEV-15532 XA: Assertion `!log->same_pk' failed in row_log_table_apply_delete
-
- Closed
-
-
MDEV-15791 XA: Server crashes in lock_release upon closing connection
-
- Closed
-
The ALGORITHM=INPLACE code in InnoDB assumes that the table is exclusively locked both at ha_innobase::prepare_inplace_alter_table() and at ha_innobase::commit_inplace_alter_table(). As a work-around for missing WL#6049 (proper metadata lock coverage for FOREIGN KEY operations), InnoDB does try to acquire exclusive transactional table locks at commit. And that is the reason why the ALTER TABLE operation goes to rollback:
transaction is holding locks on the table while we
change the table definition. The MySQL meta-data lock
should normally guarantee that no conflicting locks
exist. However, FOREIGN KEY constraints checks and any
transactions collected during crash recovery could be
holding InnoDB locks only, not MySQL locks. */
error = row_merge_lock_table(
m_prebuilt->trx, ctx->old_table, LOCK_X);
my_error_innodb(
error, table_share->table_name.str, 0);
}
The above is the code in MariaDB 10.2. After the lock timeout, the SQL layer would invoke ha_innobase::commit_inplace_alter_table(commit=false), and during this operation, the assertion inside InnoDB would fail.
This seems to demonstrate poor error handling in InnoDB. The online_log is actually owned by the ALTER TABLE operation, and InnoDB should free it on failure, instead of complaining that it exists. A similar situation should be possible when the table being ALTERed is being locked as a child or parent table of a FOREIGN KEY operation.
I will try to create a test case for this. The original test case should be fixed as part of
MDEV-15490outside InnoDB.