1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-35124 Set innodb_snapshot_isolation=ON by default

From the very beginning, the default InnoDB transaction isolation level
REPEATABLE READ does not correspond to any well formed definition.
The main issue is the lack of write/write conflict detection.
To fix that and to make REPEATABLE READ correspond to Snapshot Isolation,
b8a6719889 introduced the Boolean
session variable innodb_snapshot_isolation. It was disabled by default
in order not to break any user applications.

In a new major version of MariaDB Server, we had better enable this
parameter by default.
This commit is contained in:
Marko Mäkelä
2024-10-11 15:02:31 +03:00
parent 26dce1cec3
commit 4e1e9ea6f3
28 changed files with 35 additions and 3 deletions

View File

@ -10,6 +10,7 @@ SELECT * FROM t WHERE a = 20 FOR UPDATE;
a b
20 20
connect con_2,localhost,root,,;
SET innodb_snapshot_isolation=OFF;
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
BEGIN;
SET DEBUG_SYNC = 'lock_trx_handle_wait_enter SIGNAL upd_locked WAIT_FOR upd_cont EXECUTE 2';

View File

@ -8,6 +8,7 @@ SELECT * FROM t WHERE a = 20 FOR UPDATE;
a b
20 20
connect con_2,localhost,root,,;
SET innodb_snapshot_isolation=OFF;
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
BEGIN;
SET DEBUG_SYNC = 'lock_trx_handle_wait_before_unlocked_wait_lock_check SIGNAL upd_locked WAIT_FOR upd_cont';

View File

@ -8,6 +8,7 @@ SELECT * FROM t WHERE a = 20 FOR UPDATE;
a b
20 20
connect con_2,localhost,root,,;
SET innodb_snapshot_isolation=OFF;
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
SET DEBUG_SYNC = 'lock_trx_handle_wait_enter SIGNAL upd_locked WAIT_FOR upd_cont';
SET DEBUG_SYNC = 'trx_t_release_locks_enter SIGNAL sel_cont WAIT_FOR upd_cont_2';

View File

@ -80,6 +80,7 @@ COUNT(*)
#
# Do some DML in the default connection and leave the transaction pending.
#
SET innodb_snapshot_isolation=OFF;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
BEGIN;
UPDATE t1 SET c2 = c2 * 3 WHERE c1 = 1;
@ -140,6 +141,7 @@ COUNT(*)
# Connection 1 REPEATABLE READ
#
connect con1,localhost,root,,;
SET innodb_snapshot_isolation=OFF;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
BEGIN;
########## innodb_isolation_selects.inc ##########

View File

@ -20,6 +20,7 @@ commit;
connection a;
commit;
connection b;
set innodb_snapshot_isolation=off;
set session transaction isolation level read committed;
update t1 set a=10 where a=5;
connection a;

View File

@ -17,6 +17,7 @@ insert into `t1` (rowid, f1, f2) values (1, 1, 10), (2, 1, NULL);
connect a,localhost,root,,;
connect b,localhost,root,,;
connection a;
set innodb_snapshot_isolation=OFF;
start transaction with consistent snapshot;
connection b;
start transaction;

View File

@ -11,6 +11,7 @@ a b
1 1
2 2
connect con_weird,localhost,root;
SET innodb_snapshot_isolation=OFF;
BEGIN;
SELECT * FROM t;
a b

View File

@ -27,6 +27,7 @@ SELECT * FROM t WHERE a = 20 FOR UPDATE;
# trx 1
--connect(con_2,localhost,root,,)
SET innodb_snapshot_isolation=OFF;
# RC is neccessary to do semi-consistent read
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
BEGIN; # trx 2

View File

@ -34,6 +34,7 @@ SELECT * FROM t WHERE a = 20 FOR UPDATE;
--connect(con_2,localhost,root,,)
# RC is necessary to do semi-consistent read
SET innodb_snapshot_isolation=OFF;
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
BEGIN; # trx 2
# The first time it will be hit on trying to lock (20,20), the second hit

View File

@ -33,6 +33,7 @@ UPDATE t2 SET a = a + 100;
SELECT * FROM t WHERE a = 20 FOR UPDATE;
--connect(con_2,localhost,root,,)
SET innodb_snapshot_isolation=OFF;
# RC is necessary to do semi-consistent read
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
# It will be hit on trying to lock (20,20).

View File

@ -45,6 +45,7 @@ INSERT INTO t2 (SELECT * FROM t1);
--echo #
--echo # Do some DML in the default connection and leave the transaction pending.
--echo #
SET innodb_snapshot_isolation=OFF;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
BEGIN;
--enable_info
@ -59,6 +60,7 @@ DELETE FROM t1 WHERE c1 = 6;
--echo # Connection 1 REPEATABLE READ
--echo #
connect (con1,localhost,root,,);
SET innodb_snapshot_isolation=OFF;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
BEGIN;
--source suite/innodb/include/innodb_isolation_selects.inc

View File

@ -28,6 +28,7 @@ connection a;
commit;
connection b;
# perform a semi-consisent read (and unlock non-matching rows)
set innodb_snapshot_isolation=off;
set session transaction isolation level read committed;
update t1 set a=10 where a=5;
connection a;

View File

@ -15,6 +15,7 @@ connect (a,localhost,root,,);
connect (b,localhost,root,,);
connection a;
set innodb_snapshot_isolation=OFF;
start transaction with consistent snapshot;
connection b;

View File

@ -10,6 +10,7 @@ CREATE TABLE t(a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
INSERT INTO t VALUES (1,1),(2,2);
BEGIN; SELECT * FROM t LOCK IN SHARE MODE;
--connect con_weird,localhost,root
SET innodb_snapshot_isolation=OFF;
BEGIN;
SELECT * FROM t;
--connect consistent,localhost,root