|
1 | 1 | # ==== Purpose ====
|
2 | 2 | #
|
3 |
| -# Test many GTID-consistency violations. This file is sourced from |
4 |
| -# binlog_enforce_gtid_consistency.test; see that file for details. |
| 3 | +# Test that GTID-consistency violations generate warnings or errors, |
| 4 | +# or pass with success, as expected. |
| 5 | +# |
| 6 | +# Generally, the following statement types are considered to be GTID |
| 7 | +# consistency violations: |
| 8 | +# |
| 9 | +# 1. DML statements that mix non-transactional updates with |
| 10 | +# transactional updates. (Exception: non-transactional *temporary* |
| 11 | +# tables do not count, in case the statement is logged in row |
| 12 | +# format.) |
| 13 | +# |
| 14 | +# 2. Transactions that use non-transactional tables after having used |
| 15 | +# transactional tables. (Exception: non-transactional *temporary* |
| 16 | +# tables do not count, in case the statement is logged in row |
| 17 | +# format.) |
| 18 | +# |
| 19 | +# 3. CREATE TABLE ... SELECT. |
| 20 | +# |
| 21 | +# 4. CREATE TEMPORARY TABLE or DROP TEMPORARY TABLE within a |
| 22 | +# transaction |
| 23 | +# |
| 24 | +# A GTID-violating statement can pass with success, generate a |
| 25 | +# warning, or generate an error, according to the following rules: |
| 26 | +# |
| 27 | +# 1. If ENFORCE_GTID_CONSISTENCY=ON, or GTID_NEXT='UUID:NUMBER', or |
| 28 | +# (GTID_NEXT='AUTOMATIC' and GTID_MODE=ON or ON_PERMISSIVE), |
| 29 | +# generate an error. |
| 30 | +# |
| 31 | +# 2. Otherwise, if ENFORCE_GTID_CONSISTENCY=WARN, generate a warning. |
| 32 | +# |
| 33 | +# 3. Otherwise, statement should pass without warning or error. |
| 34 | +# |
| 35 | +# ==== Implementation ==== |
| 36 | +# |
| 37 | +# Iterate over all values of enforce_gtid_consistency. |
| 38 | +# Iterate over all values of gtid_mode. |
| 39 | +# For each gtid_next in automatic, anonymus, and GTID: |
| 40 | +# source $test_specification |
| 41 | +# |
| 42 | +# $test_specification must be set by the caller to one of: |
| 43 | +# - extra/binlog/enforce_gtid_consistency_temporary.test |
| 44 | +# - extra/binlog/enforce_gtid_consistency_create_select.test |
| 45 | +# - extra/binlog/enforce_gtid_consistency_trx_nontrx.test |
| 46 | +# |
| 47 | +# Each of |
| 48 | +# extra/binlog/enforce_gtid_consistency_[temporary|create_select|trx_nontrx].test |
| 49 | +# contains a number of specific test scenarios. Each test scenario has |
| 50 | +# a statement that will be tested. For some scenarios, the expectation |
| 51 | +# is that the statement violates GTID consistency, for other scenarios |
| 52 | +# the expectation is that the statement does not violate GTID |
| 53 | +# consistency. Each scenario sources |
| 54 | +# extra/binlog_tests/enforce_gtid_consistency_statement.inc to execute |
| 55 | +# the statement and verify that the outcome is as expected. |
| 56 | +# |
| 57 | +# ==== References ==== |
| 58 | +# |
| 59 | +# WL#3584: Global Transaction Identifiers |
| 60 | +# - Created the test. |
| 61 | +# WL#7083: GTIDs: set gtid_mode=ON online |
| 62 | +# - Rewrote the test to improve coverage and test new logic for |
| 63 | +# enforce_gtid_consistency. |
| 64 | + |
| 65 | +# This test uses ONGOING_ANONYMOUS_GTID_VIOLATING_TRANSACTION_COUNT |
| 66 | +# and ONGOING_AUTOMATIC_GTID_VIOLATING_TRANSACTION_COUNT, which are |
| 67 | +# only define in debug mode. |
| 68 | +--source include/have_debug.inc |
| 69 | +--source include/have_debug_sync.inc |
| 70 | + |
| 71 | +--source include/have_myisam.inc |
| 72 | +--source include/have_innodb.inc |
| 73 | +--let $rpl_gtid_utils= 1 |
| 74 | +--let $rpl_server_count= 1 |
| 75 | +--let $rpl_topology= none |
| 76 | +--source include/rpl_init.inc |
| 77 | + |
| 78 | +--connection server_1 |
| 79 | + |
| 80 | +# Disable warnings from binlog_format-unsafe statements, since they |
| 81 | +# confuses the logic for checking that a GTID-violation warning was |
| 82 | +# generated. |
| 83 | +--let $binlog_format= `SELECT @@SESSION.BINLOG_FORMAT` |
| 84 | +--let $binlog_direct_non_transactional_updates= `SELECT @@SESSION.BINLOG_DIRECT_NON_TRANSACTIONAL_UPDATES` |
| 85 | +SET @old_sql_notes= @@GLOBAL.SQL_NOTES; |
| 86 | +SET GLOBAL SQL_NOTES= 0; |
| 87 | +SET SESSION SQL_NOTES= 0; |
| 88 | + |
| 89 | +CALL mtr.add_suppression('Statement violates GTID consistency:'); |
| 90 | +CALL mtr.add_suppression('Unsafe statement written to the binary log'); |
| 91 | + |
| 92 | +--let $gtid_next_mask_mode= 1 |
| 93 | +--let $gtid_next_connection= default |
| 94 | + |
| 95 | +--let $statement_connection= default |
| 96 | +--let $auxiliary_connection= server_1_1 |
| 97 | + |
| 98 | +--connection $statement_connection |
| 99 | + |
| 100 | +# Foreach enforce_gtid_consistency = 0, 1, 2. |
| 101 | +--let $enforce_gtid_consistency= 0 |
| 102 | +while ($enforce_gtid_consistency < 3) |
| 103 | +{ |
| 104 | + eval SET GLOBAL ENFORCE_GTID_CONSISTENCY = $enforce_gtid_consistency; |
| 105 | + --let $enforce_gtid_consistency_text= `SELECT SUBSTRING_INDEX(SUBSTRING_INDEX('OFF,ERROR,WARN', ',', $enforce_gtid_consistency + 1), ',', -1)` |
| 106 | + |
| 107 | + # Foreach gtid_mode = [3,] 2, 1, 0. |
| 108 | + # 3 is only used when enforce_gtid_consistency=1. |
| 109 | + SET GLOBAL GTID_MODE = OFF_PERMISSIVE; |
| 110 | + SET GLOBAL GTID_MODE = ON_PERMISSIVE; |
| 111 | + if ($enforce_gtid_consistency != 1) |
| 112 | + { |
| 113 | + --let $gtid_mode= 2 |
| 114 | + } |
| 115 | + if ($enforce_gtid_consistency == 1) |
| 116 | + { |
| 117 | + --let $gtid_mode= 3 |
| 118 | + SET GLOBAL GTID_MODE = ON; |
| 119 | + } |
| 120 | + while ($gtid_mode >= 0) |
| 121 | + { |
| 122 | + eval SET GLOBAL GTID_MODE = $gtid_mode; |
| 123 | + --let $gtid_mode_text= `SELECT SUBSTRING_INDEX(SUBSTRING_INDEX('OFF,OFF_PERMISSIVE,ON_PERMISSIVE,ON', ',', $gtid_mode + 1), ',', -1)` |
| 124 | + |
| 125 | + --echo ######## ENFORCE_GTID_CONSISTENCY=$enforce_gtid_consistency_text GTID_MODE=$gtid_mode_text GTID_NEXT=AUTOMATIC ######## |
| 126 | + --let $gtid_next= AUTOMATIC |
| 127 | + --let $violation_result= $enforce_gtid_consistency |
| 128 | + if ($gtid_mode >= 2) |
| 129 | + { |
| 130 | + --let $violation_result= 1 |
| 131 | + } |
| 132 | + --source $test_file |
| 133 | + |
| 134 | + if ($gtid_mode < 3) |
| 135 | + { |
| 136 | + --echo ######## ENFORCE_GTID_CONSISTENCY=$enforce_gtid_consistency_text GTID_MODE=$gtid_mode_text GTID_NEXT=ANONYMOUS ######## |
| 137 | + --let $gtid_next= ANONYMOUS |
| 138 | + --let $violation_result= $enforce_gtid_consistency |
| 139 | + --source $test_file |
| 140 | + } |
| 141 | + if ($gtid_mode > 0) |
| 142 | + { |
| 143 | + --echo ######## ENFORCE_GTID_CONSISTENCY=$enforce_gtid_consistency_text GTID_MODE=$gtid_mode_text GTID_NEXT=GTID ######## |
| 144 | + --let $gtid_next= GTID |
| 145 | + --let $violation_result= 1 |
| 146 | + --source $test_file |
| 147 | + } |
| 148 | + |
| 149 | + --dec $gtid_mode |
| 150 | + } |
5 | 151 |
|
6 |
| ---source extra/binlog_tests/enforce_gtid_consistency_create_select.test |
| 152 | + --inc $enforce_gtid_consistency |
| 153 | +} |
7 | 154 |
|
8 |
| ---let $binlog_direct_non_transactional_updates= 0 |
9 |
| ---source extra/binlog_tests/enforce_gtid_consistency_trx_nontrx.test |
| 155 | +--connection server_1 |
10 | 156 |
|
11 |
| ---let $binlog_direct_non_transactional_updates= 1 |
12 |
| ---source extra/binlog_tests/enforce_gtid_consistency_trx_nontrx.test |
| 157 | +SET GLOBAL ENFORCE_GTID_CONSISTENCY = OFF; |
| 158 | +SET GLOBAL SQL_NOTES = @old_sql_notes; |
13 | 159 |
|
14 |
| ---source extra/binlog_tests/enforce_gtid_consistency_temporary.test |
| 160 | +--source include/rpl_end.inc |
0 commit comments