mirror of
https://github.com/MariaDB/server.git
synced 2025-02-09 23:24:11 +01:00
![Daniele Sciascia](/assets/img/avatar_default.png)
This patch fixes cases where a transaction caused empty writeset to be replicated. This could happen in the case where a transaction executes a statement that initially manages to modify some data and therefore appended keys some for certification. The statement is however rolled back at some later stage due to some error (for example, a duplicate key error). After statement rollback the transaction is still alive, has no other changes. When committing such transaction, an empty writeset was replicated through Galera. The fix is to avoid calling into commit hook only when transaction has appended one or keys for certification *and* has some data in binlog cache to replicate. Otherwise, the commit is considered empty, and goes through usual empty commit path. Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
58 lines
1.4 KiB
Text
58 lines
1.4 KiB
Text
#
|
|
# MDEV-31272: Statement rollback causes empty writeset replication
|
|
#
|
|
|
|
--source include/galera_cluster.inc
|
|
|
|
#
|
|
# Case 1: Multi statement transaction
|
|
#
|
|
--connection node_1
|
|
CREATE TABLE t1 (f1 int primary key, f2 int);
|
|
INSERT INTO t1 VALUES (1,0);
|
|
|
|
--let $replicated_old = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_replicated'`
|
|
|
|
BEGIN;
|
|
--error ER_DUP_ENTRY
|
|
INSERT INTO t1 VALUES (2,4),(1,1);
|
|
COMMIT;
|
|
|
|
--let $replicated_new = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_replicated'`
|
|
|
|
--disable_query_log
|
|
--eval SELECT $replicated_new - $replicated_old AS 'Writesets replicated (expect 0)';
|
|
--enable_query_log
|
|
|
|
--connection node_1
|
|
SELECT * FROM t1;
|
|
--connection node_2
|
|
SELECT * FROM t1;
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
#
|
|
# Case 2: autocommit statement
|
|
#
|
|
--connection node_1
|
|
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 INTEGER);
|
|
INSERT INTO t1 VALUES (1,0);
|
|
|
|
--let $replicated_old = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_replicated'`
|
|
|
|
--error ER_DUP_ENTRY
|
|
INSERT INTO t1 VALUES (2,4), (1,1);
|
|
|
|
--let $replicated_new = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_replicated'`
|
|
|
|
--disable_query_log
|
|
--eval SELECT $replicated_new - $replicated_old AS 'Writesets replicated (expect 0)';
|
|
--enable_query_log
|
|
|
|
--connection node_1
|
|
SELECT * FROM t1;
|
|
--connection node_2
|
|
SELECT * FROM t1;
|
|
|
|
DROP TABLE t1;
|