mariadb/mysql-test/suite/innodb/r/autoinc_debug.result
2024-03-12 09:19:57 +02:00

164 lines
4.7 KiB
Text

CREATE TABLE t1 (id INT AUTO_INCREMENT PRIMARY KEY)ENGINE=INNODB;
# SETTING auto_increment_increment IN CONNECTION DEFAULT
SET AUTO_INCREMENT_INCREMENT = 1;
# MDEV-24348 InnoDB shutdown hang with innodb_flush_sync=0
SET GLOBAL innodb_flush_sync=OFF;
# For the server to hang, we must have pages for temporary tables
# (and the bug depended on MDEV-12227 not being fixed).
CREATE TEMPORARY TABLE t (id SERIAL) ENGINE=InnoDB;
SET debug_dbug= '+d,ib_log_flush_ahead';
INSERT INTO t1 VALUES(NULL);
SELECT * FROM t1;
id
1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
# restart
# SETTING auto_increment_increment IN CONNECTION1
SET AUTO_INCREMENT_INCREMENT = 2;
SET DEBUG_SYNC= 'ib_after_row_insert SIGNAL opened WAIT_FOR flushed1';
INSERT INTO t1 VALUES(NULL);
connect con1, localhost, root,,;
SET AUTO_INCREMENT_INCREMENT = 2;
SET DEBUG_SYNC= 'now WAIT_FOR opened';
SET DEBUG_SYNC= 'ib_after_row_insert_step SIGNAL flushed1 WAIT_FOR opened1';
insert into t1 values(NULL);
connection default;
SELECT * FROM t1;
id
1
3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SET DEBUG_SYNC= 'now SIGNAL opened1';
connection con1;
SELECT * FROM t1;
id
1
3
5
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
connection default;
disconnect con1;
DROP TABLE t1;
CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY)ENGINE=INNODB;
# SETTING auto_increment_increment IN CONNECTION DEFAULT
SET AUTO_INCREMENT_INCREMENT = 1;
INSERT INTO t1 VALUES(NULL);
SELECT * FROM t1;
id
1
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SET DEBUG_SYNC = 'now SIGNAL flushed';
connect con1, localhost, root,,;
# SETTING auto_increment_increment in connection1
SET AUTO_INCREMENT_INCREMENT = 2;
SET DEBUG_SYNC= 'now WAIT_FOR flushed';
SET DEBUG_SYNC= 'ib_after_row_insert SIGNAL opened WAIT_FOR flushed1';
INSERT INTO t1 values(NULL);
connection default;
SET DEBUG_SYNC= 'now WAIT_FOR opened';
SET DEBUG_SYNC= 'ib_after_row_insert_step SIGNAL flushed1 WAIT_FOR opened1';
INSERT INTO t1 VALUES(NULL);
connection con1;
SELECT * FROM t1;
id
1
3
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SET DEBUG_SYNC= 'now SIGNAL opened1';
disconnect con1;
connection default;
SELECT * FROM t1;
id
1
3
5
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
DROP TABLE t1;
SET DEBUG_SYNC='RESET';
#
# MDEV-33593: Auto increment deadlock error causes ASSERT in subsequent save point
#
CREATE TABLE t1(col1 INT PRIMARY KEY AUTO_INCREMENT, col2 INT) ENGINE=InnoDB;
CREATE TABLE t2(col1 INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1(col2) values(100);
connect con1, localhost, root,,;
START TRANSACTION;
# T1: Acquiring Row X lock on table t2
INSERT INTO t2 values(100);
connect con2, localhost, root,,;
START TRANSACTION;
# T2: Wait for (T1) row lock on t2 after acquiring GAP Lock on t1
UPDATE t1 SET col2 = 20 where col1 = 10;
SET DEBUG_SYNC='lock_wait_before_suspend SIGNAL t2_waiting';
INSERT INTO t2 values(100);
connection default;
SET DEBUG_SYNC='now WAIT_FOR t2_waiting';
# T3: Wait for (T2) II row Lock on t1 after acquiring Auto Increment Lock on t1
SET DEBUG_SYNC='lock_wait_before_suspend SIGNAL t3_waiting';
INSERT INTO t1(col2) SELECT col2 from t1;
connection con1;
SAVEPOINT s1;
SET DEBUG_SYNC='now WAIT_FOR t3_waiting';
# T1: Wait for (T3) auto increment lock on t1 causing T1 -> T3 -> T2 -> T1 deadlock
SET debug_dbug = '+d,innodb_deadlock_victim_self';
INSERT INTO t1(col2) VALUES(200);
ERROR HY000: Failed to read auto-increment value from storage engine
# The transaction should have been rolled back
SELECT * FROM t1;
col1 col2
1 100
SELECT * FROM t2;
col1
# Release the previous savepoint using the same name
SAVEPOINT s1;
COMMIT;
connection con2;
COMMIT;
connection default;
COMMIT;
disconnect con1;
disconnect con2;
# Cleanup
SELECT * FROM t1;
col1 col2
1 100
2 100
DROP TABLE t1;
SELECT * FROM t2;
col1
100
DROP TABLE t2;
SET DEBUG_SYNC='RESET';
#
# End of 10.5 tests
#