mariadb/mysql-test/suite/innodb/t/innodb-autoinc-56228.test
Marko Mäkelä b82abc7163 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
2025-01-15 16:55:01 +02:00

46 lines
1.3 KiB
Text

--source include/have_innodb.inc
##
# Bug #56228: dropping tables from within an active statement crashes server
#
# This test used to use TEMPORARY TABLE, which before MySQL 5.7 or
# MariaDB Server 10.2 were covered by InnoDB locks.
# In MariaDB Server 10.6, the locking and logging was corrected for Atomic DDL.
# Hence, even if we tweaked create_table_info_t::innobase_table_flags()
# so that TEMPORARY TABLE are created as persistent tables,
# the DROP TEMPORARY TABLE statement inside the function would
# fail due to HA_ERR_LOCK_WAIT_TIMEOUT, instead of breaking locks
# like it used to do before MDEV-26603 and possibly other changes.
CREATE TABLE t1_56228(
c1 iNT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t2_56228(
c1 iNT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;
DELIMITER //;
--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
CREATE FUNCTION bug56228() RETURNS INT DETERMINISTIC
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;
RETURN 42;
END //
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 //
DELIMITER ;//
CALL bug56228();
DROP PROCEDURE bug56228;
DROP TABLE t2_56228;