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