mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-35701 trx_t::autoinc_locks causes unnecessary dynamic memory allocation
trx_t::autoinc_locks: Use small_vector<lock_t*,4> in order to avoid any dynamic memory allocation in the most common case (a statement is holding AUTO_INCREMENT locks on at most 4 tables or partitions). lock_cancel_waiting_and_release(): Instead of removing elements from the middle, simply assign nullptr, like lock_table_remove_autoinc_lock(). The added test innodb.auto_increment_lock_mode covers the dynamic memory allocation as well as nondeterministically (occasionally) covers the out-of-order lock release in lock_table_remove_autoinc_lock(). Reviewed by: Debarun Banerjee
This commit is contained in:
43
mysql-test/suite/innodb/r/auto_increment_lock_mode.result
Normal file
43
mysql-test/suite/innodb/r/auto_increment_lock_mode.result
Normal file
@@ -0,0 +1,43 @@
|
||||
CREATE TABLE t1(a TINYINT UNSIGNED AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;
|
||||
CREATE TABLE t2(a TINYINT UNSIGNED AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;
|
||||
CREATE TABLE t3(a TINYINT UNSIGNED AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;
|
||||
CREATE TABLE t4(a TINYINT UNSIGNED AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;
|
||||
CREATE TABLE t5(a TINYINT UNSIGNED AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;
|
||||
CREATE TABLE t6(a SERIAL, b INT) ENGINE=InnoDB;
|
||||
CREATE FUNCTION p1() RETURNS INT
|
||||
BEGIN
|
||||
INSERT INTO t1() VALUES();
|
||||
INSERT INTO t2() VALUES();
|
||||
INSERT INTO t3() VALUES();
|
||||
INSERT INTO t4() VALUES();
|
||||
INSERT INTO t5() VALUES();
|
||||
RETURN 1;
|
||||
END$$
|
||||
INSERT INTO t6(b) SELECT p1();
|
||||
UPDATE t1,t2,t3,t4,t5 SET t1.a=2,t2.a=2,t3.a=2,t4.a=2,t5.a=2;
|
||||
SELECT * FROM t1;
|
||||
a
|
||||
2
|
||||
connect con1,localhost,root,,;
|
||||
connect con2,localhost,root,,;
|
||||
connect con3,localhost,root,,;
|
||||
connection con1;
|
||||
INSERT INTO t6(b) SELECT SLEEP(p1());
|
||||
connection con2;
|
||||
INSERT INTO t6(b) SELECT SLEEP(p1());
|
||||
connection con3;
|
||||
UPDATE t1,t2,t3,t4,t5 SET t1.a=0,t2.a=0,t3.a=0,t4.a=0,t5.a=0
|
||||
WHERE t1.a=2 AND t2.a=2 AND t3.a=2 AND t4.a=2 AND t5.a=2;
|
||||
connection default;
|
||||
KILL QUERY $ID1;
|
||||
KILL QUERY $ID2;
|
||||
KILL QUERY $ID3;
|
||||
connection con1;
|
||||
disconnect con1;
|
||||
connection con2;
|
||||
disconnect con2;
|
||||
connection con3;
|
||||
disconnect con3;
|
||||
connection default;
|
||||
DROP FUNCTION p1;
|
||||
DROP TABLE t1,t2,t3,t4,t5,t6;
|
@@ -1,15 +1,6 @@
|
||||
DROP TABLE IF EXISTS t1_56228;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 'test.t1_56228'
|
||||
DROP TABLE IF EXISTS t2_56228;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 'test.t2_56228'
|
||||
DROP FUNCTION IF EXISTS bug56228;
|
||||
Warnings:
|
||||
Note 1305 FUNCTION test.bug56228 does not exist
|
||||
CREATE TEMPORARY TABLE t1_56228(
|
||||
CREATE TABLE t1_56228(
|
||||
c1 iNT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;
|
||||
CREATE TEMPORARY TABLE t2_56228(
|
||||
CREATE TABLE t2_56228(
|
||||
c1 iNT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;
|
||||
CREATE FUNCTION bug56228() RETURNS INT DETERMINISTIC
|
||||
BEGIN
|
||||
@@ -17,14 +8,18 @@ INSERT INTO t1_56228 VALUES(NULL);
|
||||
INSERT INTO t2_56228 VALUES(NULL);
|
||||
INSERT INTO t1_56228 VALUES(NULL);
|
||||
INSERT INTO t2_56228 VALUES(NULL);
|
||||
DROP TEMPORARY TABLE t1_56228;
|
||||
DROP TABLE t1_56228;
|
||||
RETURN 42;
|
||||
END //
|
||||
SELECT bug56228();
|
||||
bug56228()
|
||||
42
|
||||
DROP FUNCTION bug56228;
|
||||
DROP TEMPORARY TABLE t2_56228;
|
||||
DROP TEMPORARY TABLE IF EXISTS t1_56228;
|
||||
Warnings:
|
||||
Note 1051 Unknown table 'test.t1_56228'
|
||||
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger
|
||||
CREATE PROCEDURE bug56228()
|
||||
BEGIN
|
||||
INSERT INTO t1_56228 VALUES(NULL);
|
||||
INSERT INTO t2_56228 VALUES(NULL);
|
||||
INSERT INTO t1_56228 VALUES(NULL);
|
||||
INSERT INTO t2_56228 VALUES(NULL);
|
||||
DROP TABLE t1_56228;
|
||||
END //
|
||||
CALL bug56228();
|
||||
DROP PROCEDURE bug56228;
|
||||
DROP TABLE t2_56228;
|
||||
|
Reference in New Issue
Block a user