| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# This test case will check if DMLs inside XA transactions are |
| 4 |
# considered unsafe when using SBR and are being binary logged using |
| 5 |
# RBR when mixed binary log format is used. |
| 6 |
# |
| 7 |
# The Step 1 covers the unsafe warnings for SBR by forcing statement |
| 8 |
# based replication for a single XA transaction. |
| 9 |
# |
| 10 |
# The Step 2 covers the logging as RBR case by generating a workload |
| 11 |
# that would produce a deadlock on the slave applier if applied using |
| 12 |
# statements. |
| 13 |
# |
| 14 |
# ==== Related Bugs and Worklogs ==== |
| 15 |
# |
| 16 |
# Bug#25786490 XA TRANSACTIONS ARE 'UNSAFE' FOR RPL USING SBR |
| 17 |
# |
| 18 |
|
| 19 |
# This test case should only run in mixed mode replication. |
| 20 |
--source include/have_binlog_format_mixed.inc |
| 21 |
--source include/master-slave.inc |
| 22 |
|
| 23 |
--source include/rpl_connection_master.inc |
| 24 |
# Suppression of error messages |
| 25 |
CALL mtr.add_suppression('Unsafe statement written to the binary log using statement format'); |
| 26 |
|
| 27 |
CREATE TABLE t1 (c1 INT PRIMARY KEY); |
| 28 |
|
| 29 |
--echo # |
| 30 |
--echo # Step 1 - XA + SBR = warning |
| 31 |
--echo # |
| 32 |
SET SESSION binlog_format = 'STATEMENT'; |
| 33 |
XA START 'a'; |
| 34 |
# Read only queries should not produce warnings |
| 35 |
SET @one = (SELECT SUBSTRING('11', 1, 1)); |
| 36 |
--let $assert_text= Any read only query shall not throw warning inside XA with SBR |
| 37 |
--let $warnings_count= `SHOW COUNT(*) WARNINGS` |
| 38 |
--let $assert_cond= $warnings_count = 0 |
| 39 |
# The next statement should display a warning message |
| 40 |
INSERT INTO t1 VALUES (@one); |
| 41 |
--let $assert_text= Any DML shall throw warning inside XA with SBR |
| 42 |
--let $warning_code= query_get_value(SHOW WARNINGS, Code, 1) |
| 43 |
--let $expected_code= convert_error(ER_BINLOG_UNSAFE_STATEMENT) |
| 44 |
--let $assert_cond= $warning_code = $expected_code |
| 45 |
--source include/assert.inc |
| 46 |
# Read only queries should not produce warnings |
| 47 |
SET @two = (SELECT SUBSTRING('22', 1, 1)); |
| 48 |
--let $assert_text= Any read only query shall not throw warning inside XA with SBR |
| 49 |
--let $warnings_count= `SHOW COUNT(*) WARNINGS` |
| 50 |
--let $assert_cond= $warnings_count = 0 |
| 51 |
# The next statement should display a warning message |
| 52 |
INSERT INTO t1 VALUES (@two); |
| 53 |
--let $assert_text= Any DML shall throw warning inside XA with SBR |
| 54 |
--let $warning_code= query_get_value(SHOW WARNINGS, Code, 1) |
| 55 |
--let $expected_code= convert_error(ER_BINLOG_UNSAFE_STATEMENT) |
| 56 |
--let $assert_cond= $warning_code = $expected_code |
| 57 |
XA END 'a'; |
| 58 |
XA PREPARE 'a'; |
| 59 |
XA COMMIT 'a'; |
| 60 |
|
| 61 |
SET SESSION binlog_format = DEFAULT; |
| 62 |
|
| 63 |
--echo # |
| 64 |
--echo # Step 2 - XA + MIXED != deadlock |
| 65 |
--echo # |
| 66 |
BEGIN; |
| 67 |
INSERT INTO t1 VALUES (7); |
| 68 |
INSERT INTO t1 VALUES (8); |
| 69 |
COMMIT; |
| 70 |
|
| 71 |
XA START 'a'; |
| 72 |
INSERT INTO t1 VALUES (5); |
| 73 |
|
| 74 |
--source include/rpl_connection_master1.inc |
| 75 |
XA START 'b'; |
| 76 |
DELETE FROM t1 WHERE c1 > 5 AND c1 < 8; |
| 77 |
XA END 'b'; |
| 78 |
XA PREPARE 'b'; |
| 79 |
|
| 80 |
--source include/rpl_connection_master.inc |
| 81 |
XA END 'a'; |
| 82 |
XA PREPARE 'a'; |
| 83 |
XA COMMIT 'a'; |
| 84 |
|
| 85 |
--source include/rpl_connection_master1.inc |
| 86 |
XA COMMIT 'b'; |
| 87 |
|
| 88 |
--echo # |
| 89 |
--echo # Cleanup |
| 90 |
--echo # |
| 91 |
|
| 92 |
--source include/rpl_connection_master.inc |
| 93 |
DROP TABLE t1; |
| 94 |
--source include/rpl_end.inc |