I converted the input to the .test file format of the mtr tool:
--source include/have_innodb.inc
|
|
CREATE TABLE tYv10enE (ID INT AUTO_INCREMENT UNIQUE, VAL INT, c0 INT NULL UNIQUE KEY) ENGINE=InnoDB;
|
INSERT INTO tYv10enE (VAL, c0) VALUES ((ROUND (RAND() * 100000)), 10989748);
|
INSERT INTO tYv10enE (VAL, c0) VALUES ((ROUND (RAND() * 100000)), -1404643822);
|
INSERT INTO tYv10enE (VAL, c0) VALUES ((ROUND (RAND() * 100000)), -335483076);
|
INSERT INTO tYv10enE (VAL, c0) VALUES ((ROUND (RAND() * 100000)), 942162931);
|
|
--connect con1,localhost,root
|
BEGIN;
|
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
|
BEGIN;
|
SELECT * FROM tYv10enE WHERE (! ((1) | (1))) OR ( c0 <= 1 );
|
--connect con2,localhost,root
|
BEGIN;
|
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
|
BEGIN;
|
SELECT * FROM tYv10enE WHERE (! ((1) | (1))) OR ( c0 <= 1 );
|
|
--connection con1
|
DELETE FROM tYv10enE WHERE FALSE OR ( c0 >= 889101988 );
|
--connection con2
|
DELETE FROM tYv10enE WHERE FALSE OR ( c0 <= 1 );
|
COMMIT;
|
--disconnect con2
|
--connection con1
|
COMMIT;
|
--disconnect con1
|
|
--connection default
|
DROP TABLE tYv10enE;
|
With this test I can reproduce the reported phenomenon. But:
- BEGIN or START TRANSACTION does not actually do anything in InnoDB; the transaction would not be started before the first row operation. There is a START TRANSACTION WITH CONSISTENT SNAPSHOT variant that would immediately create a read view within InnoDB.
- SET SESSION TRANSACTION ISOLATION LEVEL only takes effect before the transaction is started.
- Unfortunately, no error is being flagged for a duplicated BEGIN or START TRANSACTION.
If I ensure that the transactions will be created at the expected isolation level, there will be a locking conflict, just as expected:
--source include/have_innodb.inc
|
|
CREATE TABLE tYv10enE (ID INT AUTO_INCREMENT UNIQUE, VAL INT, c0 INT NULL UNIQUE KEY) ENGINE=InnoDB;
|
INSERT INTO tYv10enE (VAL, c0) VALUES ((ROUND (RAND() * 100000)), 10989748);
|
INSERT INTO tYv10enE (VAL, c0) VALUES ((ROUND (RAND() * 100000)), -1404643822);
|
INSERT INTO tYv10enE (VAL, c0) VALUES ((ROUND (RAND() * 100000)), -335483076);
|
INSERT INTO tYv10enE (VAL, c0) VALUES ((ROUND (RAND() * 100000)), 942162931);
|
|
--connect con1,localhost,root
|
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
|
START TRANSACTION;
|
SELECT * FROM tYv10enE WHERE (! ((1) | (1))) OR ( c0 <= 1 );
|
--connect con2,localhost,root
|
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
|
START TRANSACTION;
|
SELECT * FROM tYv10enE WHERE (! ((1) | (1))) OR ( c0 <= 1 );
|
|
--connection con1
|
DELETE FROM tYv10enE WHERE FALSE OR ( c0 >= 889101988 );
|
--connection con2
|
DELETE FROM tYv10enE WHERE FALSE OR ( c0 <= 1 );
|
COMMIT;
|
--disconnect con2
|
--connection con1
|
COMMIT;
|
--disconnect con1
|
|
--connection default
|
DROP TABLE tYv10enE;
|
mysqltest: At line 21: query 'DELETE FROM tYv10enE WHERE FALSE OR ( c0 <= 1 )' failed: ER_LOCK_WAIT_TIMEOUT (1205): Lock wait timeout exceeded; try restarting transaction
|
Last, please note that if you are testing transaction isolation, you’d better enable innodb_snapshot_isolation=ON (MDEV-35124).
The behaviour of START TRANSACTION or BEGIN seems to be different from the one that is described in MDEV-6905. If the previous transaction had been committed by the second BEGIN or START TRANSACTION, then also the isolation level change should have taken effect. I think that this anomaly would qualify as a SQL layer bug. I hope that serg can comment on this.
I converted the input to the .test file format of the mtr tool:
--source include/have_innodb.inc
--connect con1,localhost,root
--connect con2,localhost,root
--connection con1
--connection con2
--disconnect con2
--connection con1
--disconnect con1
--connection default
With this test I can reproduce the reported phenomenon. But:
If I ensure that the transactions will be created at the expected isolation level, there will be a locking conflict, just as expected:
--source include/have_innodb.inc
--connect con1,localhost,root
--connect con2,localhost,root
--connection con1
--connection con2
--disconnect con2
--connection con1
--disconnect con1
--connection default
mysqltest: At line 21: query 'DELETE FROM tYv10enE WHERE FALSE OR ( c0 <= 1 )' failed: ER_LOCK_WAIT_TIMEOUT (1205): Lock wait timeout exceeded; try restarting transaction
Last, please note that if you are testing transaction isolation, you’d better enable innodb_snapshot_isolation=ON (
MDEV-35124).The behaviour of START TRANSACTION or BEGIN seems to be different from the one that is described in MDEV-6905. If the previous transaction had been committed by the second BEGIN or START TRANSACTION, then also the isolation level change should have taken effect. I think that this anomaly would qualify as a SQL layer bug. I hope that serg can comment on this.