mirror of
https://github.com/MariaDB/server.git
synced 2025-01-28 01:34:17 +01:00
515b2203c5
AVOID DEADLOCK AFTER RESTORE Analysis -------- Accessing the restored NDB table in an active multi-statement transaction was resulting in deadlock found error. MySQL Server needs to discover metadata of NDB table from data nodes after table is restored from backup. Metadata discovery happens on the first access to restored table. Current code mandates this statement to be the first one in the transaction. This is because discover needs exclusive metadata lock on the table. Lock upgrade at this point can lead to MDL deadlock and the code was written at the time when MDL deadlock detector was not present. In case when discovery attempted in the statement other than the first one in transaction ER_LOCK_DEADLOCK error is reported pessimistically. Fix: --- Removed the constraint as any potential deadlock will be handled by deadlock detector. Also changed code in discover to keep metadata locks of active transaction. Same issue was present in table auto repair scenario. Same fix is added in repair path also.
33 lines
540 B
Text
33 lines
540 B
Text
#
|
|
# 18075170 - sql node restart required to avoid deadlock after
|
|
# restore
|
|
#
|
|
CREATE TABLE t1 (id INT) ENGINE=NDBCluster;
|
|
CREATE TABLE t2 (id INT) ENGINE=NDBCluster;
|
|
INSERT INTO t1 VALUES (1);
|
|
INSERT INTO t2 VALUES (1);
|
|
DROP TABLE t1;
|
|
DROP TABLE t2;
|
|
SET autocommit = 0;
|
|
SELECT * FROM t1;
|
|
id
|
|
1
|
|
SELECT * FROM t2;
|
|
id
|
|
1
|
|
ROLLBACK;
|
|
SET autocommit = 1;
|
|
drop table t1;
|
|
drop table t2;
|
|
SET autocommit = 0;
|
|
SELECT * FROM t1;
|
|
id
|
|
1
|
|
SELECT * FROM t2;
|
|
id
|
|
1
|
|
ALTER TABLE t1 ADD val INT;
|
|
ROLLBACK;
|
|
SET autocommit = 1;
|
|
drop table t1;
|
|
drop table t2;
|