mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01: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:
parent
26dce1cec3
commit
4e1e9ea6f3
28 changed files with 35 additions and 3 deletions
|
@ -1,5 +1,7 @@
|
|||
SET @save_timeout = @@GLOBAL.innodb_lock_wait_timeout;
|
||||
SET GLOBAL innodb_lock_wait_timeout = 1;
|
||||
SET @save_snapshot_isolation = @@GLOBAL.innodb_snapshot_isolation;
|
||||
SET GLOBAL innodb_snapshot_isolation = OFF;
|
||||
SET @save_isolation = @@GLOBAL.transaction_isolation;
|
||||
SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
||||
connection default;
|
||||
|
@ -792,3 +794,4 @@ drop user mysqltest@localhost;
|
|||
SET SQL_MODE=default;
|
||||
SET GLOBAL innodb_lock_wait_timeout = @save_timeout;
|
||||
SET GLOBAL transaction_isolation = @save_isolation;
|
||||
SET GLOBAL innodb_snapshot_isolation = @save_snapshot_isolation;
|
||||
|
|
|
@ -18,6 +18,8 @@ let $engine_type= InnoDB;
|
|||
|
||||
SET @save_timeout = @@GLOBAL.innodb_lock_wait_timeout;
|
||||
SET GLOBAL innodb_lock_wait_timeout = 1;
|
||||
SET @save_snapshot_isolation = @@GLOBAL.innodb_snapshot_isolation;
|
||||
SET GLOBAL innodb_snapshot_isolation = OFF;
|
||||
SET @save_isolation = @@GLOBAL.transaction_isolation;
|
||||
SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
||||
--disable_service_connection
|
||||
|
@ -25,3 +27,4 @@ SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED;
|
|||
--enable_service_connection
|
||||
SET GLOBAL innodb_lock_wait_timeout = @save_timeout;
|
||||
SET GLOBAL transaction_isolation = @save_isolation;
|
||||
SET GLOBAL innodb_snapshot_isolation = @save_snapshot_isolation;
|
||||
|
|
|
@ -17,6 +17,7 @@ a
|
|||
3
|
||||
connection b;
|
||||
set binlog_format=mixed;
|
||||
set innodb_snapshot_isolation=OFF;
|
||||
set session transaction isolation level repeatable read;
|
||||
set autocommit=0;
|
||||
update t1 set a=10 where a=5;
|
||||
|
|
|
@ -29,6 +29,7 @@ set autocommit=0;
|
|||
select * from t1 where a=3 lock in share mode;
|
||||
connection b;
|
||||
set binlog_format=mixed;
|
||||
set innodb_snapshot_isolation=OFF;
|
||||
set session transaction isolation level repeatable read;
|
||||
set autocommit=0;
|
||||
-- error ER_LOCK_WAIT_TIMEOUT
|
||||
|
|
|
@ -77,6 +77,7 @@ COUNT(DISTINCT node_uuid) = 1
|
|||
wsrep_gcomm_uuid_match
|
||||
1
|
||||
connection node_1;
|
||||
SET innodb_snapshot_isolation=OFF;
|
||||
INSERT INTO t1 VALUES (30);
|
||||
INSERT INTO t1 VALUES (31);
|
||||
INSERT INTO t1 VALUES (32);
|
||||
|
|
|
@ -138,6 +138,7 @@ SELECT COUNT(DISTINCT node_uuid) = 1 FROM mysql.wsrep_streaming_log;
|
|||
#
|
||||
|
||||
--connection node_1
|
||||
SET innodb_snapshot_isolation=OFF;
|
||||
INSERT INTO t1 VALUES (30);
|
||||
INSERT INTO t1 VALUES (31);
|
||||
INSERT INTO t1 VALUES (32);
|
||||
|
|
|
@ -22,6 +22,7 @@ DROP TABLE t1;
|
|||
DROP TABLE t2;
|
||||
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 CHAR(10)) ENGINE=InnoDB;
|
||||
connection node_1;
|
||||
SET innodb_snapshot_isolation = OFF;
|
||||
SET SESSION wsrep_trx_fragment_size = 1;
|
||||
START TRANSACTION;
|
||||
INSERT INTO t1 VALUES (1, 'node1');
|
||||
|
|
|
@ -31,6 +31,7 @@ SET GLOBAL wsrep_cluster_address = '';
|
|||
SET SESSION wsrep_sync_wait = 0;
|
||||
SET SESSION wsrep_sync_wait = default;
|
||||
connection node_1;
|
||||
SET innodb_snapshot_isolation=OFF;
|
||||
INSERT INTO t1 VALUES (6);
|
||||
INSERT INTO t1 VALUES (7);
|
||||
INSERT INTO t1 VALUES (8);
|
||||
|
|
|
@ -24,6 +24,7 @@ SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log;
|
|||
COUNT(*) = 0
|
||||
1
|
||||
connection node_1;
|
||||
SET innodb_snapshot_isolation=OFF;
|
||||
INSERT INTO t1 VALUES (REPEAT('d', 512));
|
||||
INSERT INTO t1 VALUES (REPEAT('e', 512));
|
||||
INSERT INTO t1 VALUES (REPEAT('f', 512));
|
||||
|
|
|
@ -39,6 +39,7 @@ DROP TABLE t2;
|
|||
#
|
||||
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 CHAR(10)) ENGINE=InnoDB;
|
||||
--connection node_1
|
||||
SET innodb_snapshot_isolation = OFF;
|
||||
SET SESSION wsrep_trx_fragment_size = 1;
|
||||
START TRANSACTION;
|
||||
INSERT INTO t1 VALUES (1, 'node1');
|
||||
|
|
|
@ -58,6 +58,7 @@ SET SESSION wsrep_sync_wait = default;
|
|||
|
||||
# Continue generating events in the transaction
|
||||
|
||||
SET innodb_snapshot_isolation=OFF;
|
||||
INSERT INTO t1 VALUES (6);
|
||||
INSERT INTO t1 VALUES (7);
|
||||
INSERT INTO t1 VALUES (8);
|
||||
|
|
|
@ -38,6 +38,7 @@ SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log;
|
|||
# Confirm that the transaction can be restarted on either node
|
||||
|
||||
--connection node_1
|
||||
SET innodb_snapshot_isolation=OFF;
|
||||
INSERT INTO t1 VALUES (REPEAT('d', 512));
|
||||
INSERT INTO t1 VALUES (REPEAT('e', 512));
|
||||
INSERT INTO t1 VALUES (REPEAT('f', 512));
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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 ##########
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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).
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1353,8 +1353,8 @@ ENUM_VALUE_LIST NULL
|
|||
READ_ONLY NO
|
||||
COMMAND_LINE_ARGUMENT OPTIONAL
|
||||
VARIABLE_NAME INNODB_SNAPSHOT_ISOLATION
|
||||
SESSION_VALUE OFF
|
||||
DEFAULT_VALUE OFF
|
||||
SESSION_VALUE ON
|
||||
DEFAULT_VALUE ON
|
||||
VARIABLE_SCOPE SESSION
|
||||
VARIABLE_TYPE BOOLEAN
|
||||
VARIABLE_COMMENT Use snapshot isolation (write-write conflict detection)
|
||||
|
|
|
@ -871,7 +871,7 @@ static MYSQL_THDVAR_BOOL(table_locks, PLUGIN_VAR_OPCMDARG,
|
|||
|
||||
static MYSQL_THDVAR_BOOL(snapshot_isolation, PLUGIN_VAR_OPCMDARG,
|
||||
"Use snapshot isolation (write-write conflict detection)",
|
||||
NULL, NULL, FALSE);
|
||||
NULL, NULL, TRUE);
|
||||
|
||||
static MYSQL_THDVAR_BOOL(strict_mode, PLUGIN_VAR_OPCMDARG,
|
||||
"Use strict mode when evaluating create options",
|
||||
|
|
Loading…
Reference in a new issue