| 1 |
################################################################################ |
| 2 |
# WL#6833: GCS Replication: Read-set free Certification |
| 3 |
# Module (DBSM Snapshot Isolation) |
| 4 |
# |
| 5 |
# Scenario 5: Replicate from a server into a group with |
| 6 |
# conflicts detected from server to group. |
| 7 |
# |
| 8 |
# T1: WS={t1.c1=0, t1.c1=3} |
| 9 |
# T2: WS={t1.c1=1, t1.c1=2} |
| 10 |
# |
| 11 |
# Outcome: T1 must abort, T2 must commit. |
| 12 |
# |
| 13 |
# Verify Group Replication behaviour when we establish a |
| 14 |
# asynchronous replication connection from a server to a group |
| 15 |
# and that connection is present to conflicts. |
| 16 |
# |
| 17 |
# Test: |
| 18 |
# 0. The test requires three servers: M1, M2 and M3. |
| 19 |
# 1. Setup GR on two servers (M1 and M2). |
| 20 |
# 2. Setup asynchronous replication connection from M3 into group(M1) |
| 21 |
# i.e. M3 -> M1. |
| 22 |
# 3. Execute some transactions on M3. |
| 23 |
# 4. Wait until transactions executed on M3 are applied on group. |
| 24 |
# 5. Make M1 block before message broadcast to group, using DEBUG point. Then, |
| 25 |
# commit a transaction (T1) on M3 that won't replicate to group due to |
| 26 |
# conflicts with T1. |
| 27 |
# 6. Wait until M1 SQL thread from M3 reaches the debug sync point. |
| 28 |
# 7. Commit a transaction (T2) on group on M2. |
| 29 |
# 8. Resume message broadcast to group on M1. Check that conflict was detected |
| 30 |
# on asynchronous replication connection. Expect ER3101 on M1. |
| 31 |
# 9. Force conflicting transaction on group, by committing a empty transaction |
| 32 |
# with the same GTID. No data merge is done. Commit a new transaction on M3 |
| 33 |
# to assert that asynchronous replication is working properly. |
| 34 |
# 10. Wait until transactions executed on M3 are applied on group. |
| 35 |
# 11. Validate data on M3. |
| 36 |
# 12. Validate data on M1. GTID_EXECUTED on M1 must have GTID_EXECUTED from M3. |
| 37 |
# 13. Validate data on M2. GTID_EXECUTED on M2 must have GTID_EXECUTED from M3. |
| 38 |
# 14. Clean data. |
| 39 |
# 15. Stop asynchronous replication connection from M3 into group(M1). |
| 40 |
# 16. Stop Group Replication on M1 and M2. |
| 41 |
# 17. Uninstall GTID utils. |
| 42 |
################################################################################ |
| 43 |
|
| 44 |
--source include/have_debug.inc |
| 45 |
--source include/have_debug_sync.inc |
| 46 |
--let $group_replication_group_name= 8a94f357-aab4-11df-86ab-c80aa9420004 |
| 47 |
--source include/have_group_replication_plugin.inc |
| 48 |
--let $rpl_skip_group_replication_start= 1 |
| 49 |
--let $rpl_server_count= 3 |
| 50 |
--source include/group_replication.inc |
| 51 |
|
| 52 |
# Keep binary logs with only GTIDs from test. |
| 53 |
--connection server1 |
| 54 |
SET SESSION sql_log_bin= 0; |
| 55 |
--source include/gtid_utils.inc |
| 56 |
SET SESSION sql_log_bin= 1; |
| 57 |
--connection server2 |
| 58 |
SET SESSION sql_log_bin= 0; |
| 59 |
--source include/gtid_utils.inc |
| 60 |
SET SESSION sql_log_bin= 1; |
| 61 |
--connection server3 |
| 62 |
SET SESSION sql_log_bin= 0; |
| 63 |
--source include/gtid_utils.inc |
| 64 |
SET SESSION sql_log_bin= 1; |
| 65 |
|
| 66 |
|
| 67 |
--echo |
| 68 |
--echo ############################################################ |
| 69 |
--echo # 1. Setup Group Replication on server 1 and 2. |
| 70 |
--connection server1 |
| 71 |
--source include/start_and_bootstrap_group_replication.inc |
| 72 |
|
| 73 |
--connection server2 |
| 74 |
--source include/start_group_replication.inc |
| 75 |
|
| 76 |
--let $group_replication_number_of_members= 2 |
| 77 |
--source include/gr_wait_for_number_of_members.inc |
| 78 |
|
| 79 |
|
| 80 |
--echo |
| 81 |
--echo ############################################################ |
| 82 |
--echo # 2. Setup a asynchronous replication connection from server 3 |
| 83 |
--echo # into group (server 1) |
| 84 |
--connection server1 |
| 85 |
--replace_result $SERVER_MYPORT_3 SERVER_3_PORT |
| 86 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST="127.0.0.1", SOURCE_USER="root", SOURCE_PASSWORD="", SOURCE_PORT=$SERVER_MYPORT_3, SOURCE_AUTO_POSITION=1 FOR CHANNEL "" |
| 87 |
--source include/start_slave.inc |
| 88 |
|
| 89 |
|
| 90 |
--echo |
| 91 |
--echo ############################################################ |
| 92 |
--echo # 3. Execute some transactions on server 3. |
| 93 |
--connection server3 |
| 94 |
--eval SET GTID_NEXT= '$uuida:1' |
| 95 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 96 |
SET GTID_NEXT= 'AUTOMATIC'; |
| 97 |
|
| 98 |
--eval SET GTID_NEXT= '$uuida:2' |
| 99 |
INSERT INTO t1 VALUES (0); |
| 100 |
SET GTID_NEXT= 'AUTOMATIC'; |
| 101 |
|
| 102 |
|
| 103 |
--echo |
| 104 |
--echo ############################################################ |
| 105 |
--echo # 4. Wait until transactions executed on server 3 are |
| 106 |
--echo # applied on group. |
| 107 |
--connection server3 |
| 108 |
--let $sync_slave_connection= server1 |
| 109 |
--source include/sync_slave_sql_with_master.inc |
| 110 |
--connection server3 |
| 111 |
--let $sync_slave_connection= server2 |
| 112 |
--source include/sync_slave_sql_with_master.inc |
| 113 |
|
| 114 |
|
| 115 |
--echo |
| 116 |
--echo ############################################################ |
| 117 |
--echo # 5. Commit a transaction (T1) on server 3 that won't |
| 118 |
--echo # replicate to group due to conflicts with T1. |
| 119 |
--echo # Before that make server 1 block before message |
| 120 |
--echo # broadcast to group. |
| 121 |
--connection server1 |
| 122 |
--source include/stop_slave.inc |
| 123 |
SET @server1_debug_save= @@GLOBAL.DEBUG; |
| 124 |
SET @@GLOBAL.DEBUG= '+d,debug.wait_after_set_snapshot_version_on_transaction_context_log_event'; |
| 125 |
--source include/start_slave.inc |
| 126 |
|
| 127 |
--connection server3 |
| 128 |
--eval SET GTID_NEXT= '$uuida:3' |
| 129 |
UPDATE t1 SET c1=3 WHERE c1=0; |
| 130 |
SET GTID_NEXT= 'AUTOMATIC'; |
| 131 |
|
| 132 |
|
| 133 |
--echo |
| 134 |
--echo ############################################################ |
| 135 |
--echo # 6. Wait until server 1 SQL thread from server 3 reaches |
| 136 |
--echo # the debug sync point: |
| 137 |
--echo # wait_after_set_snapshot_version_on_transaction_context_log_event |
| 138 |
--let $rpl_connection_name= server1 |
| 139 |
--source include/rpl_connection.inc |
| 140 |
--let $wait_condition=SELECT COUNT(*)=1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE State = 'debug sync point: now' |
| 141 |
--source include/wait_condition.inc |
| 142 |
|
| 143 |
|
| 144 |
--echo |
| 145 |
--echo ############################################################ |
| 146 |
--echo # 7. Commit a transaction (T2) on group on server 2. |
| 147 |
--connection server2 |
| 148 |
UPDATE t1 SET c1=2 WHERE c1=0; |
| 149 |
|
| 150 |
|
| 151 |
--echo |
| 152 |
--echo ############################################################ |
| 153 |
--echo # 8. Resume message broadcast to group on server 1. |
| 154 |
--echo # Check that conflict was detected on asynchronous |
| 155 |
--echo # replication connection. |
| 156 |
--connection server1 |
| 157 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 158 |
SET DEBUG_SYNC= 'now SIGNAL signal.resume_after_set_snapshot_version_on_transaction_context_log_event'; |
| 159 |
|
| 160 |
--connection server2 |
| 161 |
--let $sync_slave_connection= server1 |
| 162 |
--source include/sync_slave_sql_with_master.inc |
| 163 |
|
| 164 |
--let $slave_sql_errno= convert_error(ER_TRANSACTION_ROLLBACK_DURING_COMMIT) |
| 165 |
--source include/wait_for_slave_sql_error.inc |
| 166 |
|
| 167 |
SET DEBUG_SYNC= 'RESET'; |
| 168 |
|
| 169 |
SET SESSION sql_log_bin= 0; |
| 170 |
call mtr.add_suppression("Replica SQL for channel '': Error in Xid_log_event: Commit could not be completed, 'Plugin instructed the server to rollback the current transaction.', Error_code:.*"); |
| 171 |
call mtr.add_suppression("Replica: Plugin instructed the server to rollback the current transaction. Error_code:.*"); |
| 172 |
call mtr.add_suppression("Replica SQL for channel '': Worker.* failed executing transaction"); |
| 173 |
call mtr.add_suppression(".*The replica coordinator and worker threads are stopped.*"); |
| 174 |
SET SESSION sql_log_bin= 1; |
| 175 |
|
| 176 |
|
| 177 |
--echo |
| 178 |
--echo ############################################################ |
| 179 |
--echo # 9. Force conflicting transaction on group, by committing |
| 180 |
--echo # a empty transaction with the same GTID. No data merge |
| 181 |
--echo # is done. |
| 182 |
--echo # Commit a new transaction on server 3 to assert that |
| 183 |
--echo # asynchronous replication is working properly. |
| 184 |
--connection server1 |
| 185 |
--eval SET GTID_NEXT= '$uuida:3' |
| 186 |
BEGIN; |
| 187 |
COMMIT; |
| 188 |
SET GTID_NEXT= 'AUTOMATIC'; |
| 189 |
--source include/rpl_sync.inc |
| 190 |
|
| 191 |
--source include/start_slave_sql.inc |
| 192 |
|
| 193 |
--connection server3 |
| 194 |
--eval SET GTID_NEXT= '$uuida:4' |
| 195 |
INSERT INTO t1 VALUES (4); |
| 196 |
SET GTID_NEXT= 'AUTOMATIC'; |
| 197 |
|
| 198 |
|
| 199 |
--echo |
| 200 |
--echo ############################################################ |
| 201 |
--echo # 10. Wait until transactions executed on server 3 are |
| 202 |
--echo # applied on group. |
| 203 |
--connection server3 |
| 204 |
--let $sync_slave_connection= server1 |
| 205 |
--source include/sync_slave_sql_with_master.inc |
| 206 |
--connection server3 |
| 207 |
--let $sync_slave_connection= server2 |
| 208 |
--source include/sync_slave_sql_with_master.inc |
| 209 |
|
| 210 |
|
| 211 |
--echo |
| 212 |
--echo ############################################################ |
| 213 |
--echo # 11. Validate data on server 3. |
| 214 |
--connection server3 |
| 215 |
--let $assert_text= GTID_EXECUTED must contain all committed GTIDs |
| 216 |
--let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, "$uuida:1-4") |
| 217 |
--source include/assert.inc |
| 218 |
|
| 219 |
--let $assert_text= 'There is no value 0 in table t1' |
| 220 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 0, count, 1] = 0 |
| 221 |
--source include/assert.inc |
| 222 |
--let $assert_text= 'There is no value 2 in table t1' |
| 223 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 2, count, 1] = 0 |
| 224 |
--source include/assert.inc |
| 225 |
--let $assert_text= 'There is a value 3 in table t1' |
| 226 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 3, count, 1] = 1 |
| 227 |
--source include/assert.inc |
| 228 |
--let $assert_text= 'There is a value 4 in table t1' |
| 229 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 4, count, 1] = 1 |
| 230 |
--source include/assert.inc |
| 231 |
|
| 232 |
|
| 233 |
--echo |
| 234 |
--echo ############################################################ |
| 235 |
--echo # 12. GTID_EXECUTED on server 1 must contain GTID_EXECUTED |
| 236 |
--echo # from server 3. |
| 237 |
--echo # Validate data on server 1. |
| 238 |
--connection server1 |
| 239 |
--let $group_expected_gtid_set= "8a94f357-aab4-11df-86ab-c80aa9420004:1-3,$uuida:1-4" |
| 240 |
--let $assert_text= GTID_EXECUTED must contain server 3 GTID_EXECUTED |
| 241 |
--let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, $group_expected_gtid_set) |
| 242 |
--source include/assert.inc |
| 243 |
|
| 244 |
--let $assert_text= 'There is no value 0 in table t1' |
| 245 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 0, count, 1] = 0 |
| 246 |
--source include/assert.inc |
| 247 |
--let $assert_text= 'There is a value 2 in table t1' |
| 248 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 2, count, 1] = 1 |
| 249 |
--source include/assert.inc |
| 250 |
--let $assert_text= 'There is no value 3 in table t1' |
| 251 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 3, count, 1] = 0 |
| 252 |
--source include/assert.inc |
| 253 |
--let $assert_text= 'There is a value 4 in table t1' |
| 254 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 4, count, 1] = 1 |
| 255 |
--source include/assert.inc |
| 256 |
|
| 257 |
|
| 258 |
--echo |
| 259 |
--echo ############################################################ |
| 260 |
--echo # 13. GTID_EXECUTED on server 2 must contain GTID_EXECUTED |
| 261 |
--echo # from server 3. |
| 262 |
--echo # Validate data on server 2. |
| 263 |
--connection server2 |
| 264 |
--let $assert_text= GTID_EXECUTED must contain server 3 GTID_EXECUTED |
| 265 |
--let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, $group_expected_gtid_set) |
| 266 |
--source include/assert.inc |
| 267 |
|
| 268 |
--let $assert_text= 'There is no value 0 in table t1' |
| 269 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 0, count, 1] = 0 |
| 270 |
--source include/assert.inc |
| 271 |
--let $assert_text= 'There is a value 2 in table t1' |
| 272 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 2, count, 1] = 1 |
| 273 |
--source include/assert.inc |
| 274 |
--let $assert_text= 'There is no value 3 in table t1' |
| 275 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 3, count, 1] = 0 |
| 276 |
--source include/assert.inc |
| 277 |
--let $assert_text= 'There is a value 4 in table t1' |
| 278 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 4, count, 1] = 1 |
| 279 |
--source include/assert.inc |
| 280 |
|
| 281 |
|
| 282 |
--echo |
| 283 |
--echo ############################################################ |
| 284 |
--echo # 14. Clean data. |
| 285 |
--connection server3 |
| 286 |
DROP TABLE t1; |
| 287 |
|
| 288 |
--let $sync_slave_connection= server1 |
| 289 |
--source include/sync_slave_sql_with_master.inc |
| 290 |
--connection server3 |
| 291 |
--let $sync_slave_connection= server2 |
| 292 |
--source include/sync_slave_sql_with_master.inc |
| 293 |
|
| 294 |
|
| 295 |
--echo |
| 296 |
--echo ############################################################ |
| 297 |
--echo # 15. Stop asynchronous replication connection from server 3 |
| 298 |
--echo # into group (server 1) |
| 299 |
--connection server1 |
| 300 |
--source include/stop_slave.inc |
| 301 |
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION=0 FOR CHANNEL ""; |
| 302 |
|
| 303 |
--echo |
| 304 |
--echo ############################################################ |
| 305 |
--echo # 16. Stop Group Replication on server 1 and 2. |
| 306 |
--connection server1 |
| 307 |
--source include/stop_group_replication.inc |
| 308 |
|
| 309 |
--connection server2 |
| 310 |
--source include/stop_group_replication.inc |
| 311 |
|
| 312 |
|
| 313 |
--echo |
| 314 |
--echo ############################################################ |
| 315 |
--echo # 17. Uninstall GTID utils. |
| 316 |
--connection server1 |
| 317 |
SET SESSION sql_log_bin= 0; |
| 318 |
--source include/gtid_utils_end.inc |
| 319 |
SET SESSION sql_log_bin= 1; |
| 320 |
--connection server2 |
| 321 |
SET SESSION sql_log_bin= 0; |
| 322 |
--source include/gtid_utils_end.inc |
| 323 |
SET SESSION sql_log_bin= 1; |
| 324 |
--connection server3 |
| 325 |
SET SESSION sql_log_bin= 0; |
| 326 |
--source include/gtid_utils_end.inc |
| 327 |
SET SESSION sql_log_bin= 1; |
| 328 |
|
| 329 |
--source include/group_replication_end.inc |