mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Bug #29154: LOCK TABLES is not atomic when >1 InnoDB tables are locked
LOCK TABLES takes a list of tables to lock. It may lock several tables successfully and then encounter a tables that it can't lock, e.g. because it's locked. In such case it needs to undo the locks on the already locked tables. And it does that. But it has also notified the relevant table storage engine handlers that they should lock. The only reliable way to ensure that the table handlers will give up their locks is to end the transaction. This is what UNLOCK TABLE does : it ends the transaction if there were locked tables by LOCK tables. It is possible to end the transaction when the lock fails in LOCK TABLES because LOCK TABLES ends the transaction at its start already. Fixed by ending (again) the transaction when LOCK TABLES fails to lock a table.
This commit is contained in:
@ -661,4 +661,19 @@ UPDATE t3 SET a = 'us' WHERE a = 'uk';
|
||||
SELECT * FROM t3 WHERE a = 'uk';
|
||||
a
|
||||
DROP TABLE t1,t2,t3;
|
||||
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
|
||||
CREATE TABLE t2 (a INT) ENGINE=InnoDB;
|
||||
switch to connection c1
|
||||
SET AUTOCOMMIT=0;
|
||||
INSERT INTO t2 VALUES (1);
|
||||
switch to connection c2
|
||||
SET AUTOCOMMIT=0;
|
||||
LOCK TABLES t1 READ, t2 READ;
|
||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
||||
switch to connection c1
|
||||
COMMIT;
|
||||
INSERT INTO t1 VALUES (1);
|
||||
switch to connection default
|
||||
SET AUTOCOMMIT=default;
|
||||
DROP TABLE t1,t2;
|
||||
End of 5.0 tests
|
||||
|
Reference in New Issue
Block a user