mariadb/mysql-test/suite/galera/r/MDEV-37229.result
Denis Protivensky ba6e0cbd1f MDEV-37229: Set proper trx isolation level for Wsrep system threads
Every Wsrep system thread should run with READ_COMMITTED transaction
isolation level to prevent issues caused by InnoDB gap locks.

The exception is statement-based replication for appliers, where
REPEATABLE_READ is required by the server code. To account for that,
set the isolation level before every applied event. It won't affect
an already running transaction, but allows to handle both statement-
and row-based replications accordingly.
However, the problem might arise with the mixed replication format.

Apart from that, there was a separate issue with applier thread vars:
wsrep_plugins_post_init() would overwrite thd->variables for every
applier thread and forget to restore proper default isolation level.
Then, upon every server transaction termination,
trans_reset_one_shot_statistics() would set thread's isolation
level to the one stored in thd->variables, thus spoiling the isolation
level value for appliers.
2025-12-16 14:40:46 +02:00

53 lines
1.7 KiB
Text

connection node_2;
connection node_1;
connection node_2;
connection node_1;
CREATE TABLE t1 (i INT NOT NULL PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
SET GLOBAL wsrep_forced_binlog_format='STATEMENT';
START TRANSACTION;
INSERT INTO t1(i) VALUES(NULL);
Warnings:
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave
INSERT INTO t1(i) VALUES(NULL);
Warnings:
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave
SET GLOBAL wsrep_forced_binlog_format='ROW';
INSERT INTO t1(i) VALUES(NULL);
INSERT INTO t1(i) VALUES(NULL);
COMMIT;
SET GLOBAL wsrep_forced_binlog_format='ROW';
START TRANSACTION;
INSERT INTO t1(i) VALUES(NULL);
INSERT INTO t1(i) VALUES(NULL);
SET GLOBAL wsrep_forced_binlog_format='STATEMENT';
INSERT INTO t1(i) VALUES(NULL);
Warnings:
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave
INSERT INTO t1(i) VALUES(NULL);
Warnings:
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system variable that may have a different value on the slave
COMMIT;
SELECT * FROM t1 ORDER BY i;
i
1
3
5
7
9
11
13
15
connection node_2;
SELECT * FROM t1 ORDER BY i;
i
1
3
5
7
9
11
13
15
connection node_1;
SET GLOBAL wsrep_forced_binlog_format='NONE';
DROP TABLE t1;