mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Backport of revno: 2617.68.37
Bug #46654 False deadlock on concurrent DML/DDL with partitions, inconsistent behavior The problem was that if one connection is running a multi-statement transaction which involves a single partitioned table, and another connection attempts to alter the table, the first connection gets ER_LOCK_DEADLOCK and cannot proceed anymore, even when the ALTER TABLE statement in another connection has timed out or failed. The reason for this was that the prepare phase for ALTER TABLE for partitioned tables removed all instances of the table from the table definition cache before it started waiting on the lock. The transaction running in the first connection would notice this and report ER_LOCK_DEADLOCK. This patch changes the prep_alter_part_table() ALTER TABLE code so that tdc_remove_table() is no longer called. Instead, only the TABLE instance changed by prep_alter_part_table() is marked as needing reopen. The patch also removes an unnecessary call to tdc_remove_table() from mysql_unpack_partition() as the changed TABLE object is destroyed by the caller at a later point. Test case added in partition_sync.test.
This commit is contained in:
@ -1,2 +1,34 @@
|
||||
# Disabled until Bug#46654 False deadlock on concurrent DML/DDL
|
||||
# with partitions, inconsistent behavior is backported
|
||||
#
|
||||
# Bug #46654 False deadlock on concurrent DML/DDL
|
||||
# with partitions, inconsistent behavior
|
||||
#
|
||||
DROP TABLE IF EXISTS tbl_with_partitions;
|
||||
CREATE TABLE tbl_with_partitions ( i INT )
|
||||
PARTITION BY HASH(i);
|
||||
INSERT INTO tbl_with_partitions VALUES (1);
|
||||
# Connection 3
|
||||
LOCK TABLE tbl_with_partitions READ;
|
||||
# Connection 1
|
||||
# Access table with disabled autocommit
|
||||
SET AUTOCOMMIT = 0;
|
||||
SELECT * FROM tbl_with_partitions;
|
||||
i
|
||||
1
|
||||
# Connection 2
|
||||
# Alter table, abort after prepare
|
||||
set session debug="+d,abort_copy_table";
|
||||
ALTER TABLE tbl_with_partitions ADD COLUMN f INT;
|
||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
||||
# Connection 1
|
||||
# Try accessing the table after Alter aborted.
|
||||
# This used to give ER_LOCK_DEADLOCK.
|
||||
SELECT * FROM tbl_with_partitions;
|
||||
i
|
||||
1
|
||||
# Connection 3
|
||||
UNLOCK TABLES;
|
||||
# Connection 1
|
||||
# Cleanup
|
||||
DROP TABLE tbl_with_partitions;
|
||||
|
Reference in New Issue
Block a user