Browse Source
MDEV-36330: SERIALIZABLE read inconsistency
MDEV-36330: SERIALIZABLE read inconsistency
At TRANSACTION ISOLATION LEVEL SERIALIZABLE, InnoDB would fail to flag a write/read conflict, which would be a violation already at the more relaxed REPEATABLE READ level when innodb_snapshot_isolation=ON. Fix: Create a read view and start the transaction at the same time. Thus, lock checks will be able to consult the correct read view to flag ER_CHECKREAD if we are about to lock a record that was committed after the start of our transaction. innobase_start_trx_and_assign_read_view(): At any other isolation level than READ UNCOMMITTED, do create a read view. This is needed for the correct operation of START TRANSACTION WITH CONSISTENT SNAPSHOT. ha_innobase::store_lock(): At SERIALIZABLE isolation level, if the transaction was not started yet, start it and open a read view. An alternative way to achieve this would be to make trans_begin() treat START TRANSACTION (or BEGIN) in the same way as START TRANSACTION WITH CONSISTENT SNAPSHOT when the isolation level is SERIALIZABLE. innodb_isolation_level(const THD*): A simpler version of innobase_map_isolation_level(). Compared to earlier, we will return READ UNCOMMITTED also if the :newraw option is set for the InnoDB system tablespace. Reviewed by: Vladislav Lesinpull/4050/head
6 changed files with 128 additions and 75 deletions
-
52mysql-test/suite/innodb/r/lock_isolation.result
-
46mysql-test/suite/innodb/t/lock_isolation.test
-
82storage/innobase/handler/ha_innodb.cc
-
10storage/innobase/mysql-test/storage_engine/trx/cons_snapshot_serializable.rdiff
-
11storage/innobase/mysql-test/storage_engine/trx/level_read_committed.rdiff
-
2storage/innobase/mysql-test/storage_engine/trx/level_read_uncommitted.rdiff
@ -1,11 +0,0 @@ |
|||
--- suite/storage_engine/trx/level_read_committed.result |
|||
+++ suite/storage_engine/trx/level_read_committed.reject |
|||
@@ -77,6 +77,8 @@ |
|||
CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>; |
|||
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; |
|||
START TRANSACTION WITH CONSISTENT SNAPSHOT; |
|||
+Warnings: |
|||
+Warning 138 InnoDB: WITH CONSISTENT SNAPSHOT was ignored because this phrase can only be used with REPEATABLE READ isolation level. |
|||
connection con2; |
|||
INSERT INTO t1 (a) VALUES (1); |
|||
connection con1; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue