| 1 |
################################################################################ |
| 2 |
# Test that evaluates the safe guards that stop members from joining with |
| 3 |
# transactions not present in the group. |
| 4 |
# |
| 5 |
# Here we test that a joiner can enter the group when it has more executed GTIDs |
| 6 |
# than the group in its total, but the group has also some received transactions. |
| 7 |
# In total the group has more transactions than the joiner, so it can join. |
| 8 |
# |
| 9 |
# Test guide: |
| 10 |
# 0) The test requires three servers: M1, M2 and M3. |
| 11 |
# 1) With all the 3 members ONLINE, create a table on M1. Check 4 transactions |
| 12 |
# belonging to the GROUP on M2 and M3. Block the applier on M2 so it can't |
| 13 |
# apply remote transactions. |
| 14 |
# 2) Execute more transaction on M1. Check 6 transactions belonging to the |
| 15 |
# GROUP on M3 then make M3 leave. |
| 16 |
# 3) Execute some more transactions and check M2 has applied none. |
| 17 |
# 4) Remove M1. |
| 18 |
# 5) Try add M3 back to the group. Check that M3 has more executed |
| 19 |
# transactions than M2. M3 can still join the group because M2 (the group) |
| 20 |
# has more transactions when we take into account its received |
| 21 |
# transactions. Start the applier on M2. Check M3 is ONLINE. |
| 22 |
# 6) Clean up. |
| 23 |
################################################################################ |
| 24 |
|
| 25 |
--source include/big_test.inc |
| 26 |
--source include/have_debug_sync.inc |
| 27 |
--let $group_replication_group_name= 3d4bc080-ec58-11e5-a837-0800200c9a66 |
| 28 |
--source include/have_group_replication_plugin.inc |
| 29 |
--let $rpl_server_count= 3 |
| 30 |
--source include/group_replication.inc |
| 31 |
|
| 32 |
--echo # |
| 33 |
--echo # Create a table for testing on server 1 |
| 34 |
--echo # |
| 35 |
|
| 36 |
--let $rpl_connection_name= server1 |
| 37 |
--source include/rpl_connection.inc |
| 38 |
|
| 39 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 40 |
|
| 41 |
--source include/rpl_sync.inc |
| 42 |
|
| 43 |
--let $rpl_connection_name= server2 |
| 44 |
--source include/rpl_connection.inc |
| 45 |
|
| 46 |
--let $assert_text= Server 2 has 4 transaction belonging to the group |
| 47 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$group_replication_group_name:1-4"; |
| 48 |
--source include/assert.inc |
| 49 |
|
| 50 |
--let $rpl_connection_name= server3 |
| 51 |
--source include/rpl_connection.inc |
| 52 |
|
| 53 |
--let $assert_text= Server 3 has 4 transaction belonging to the group |
| 54 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$group_replication_group_name:1-4"; |
| 55 |
--source include/assert.inc |
| 56 |
|
| 57 |
--echo # |
| 58 |
--echo # Step 1: Block the applier on server 2. |
| 59 |
--echo # |
| 60 |
|
| 61 |
--let $rpl_connection_name= server2 |
| 62 |
--source include/rpl_connection.inc |
| 63 |
|
| 64 |
SET @@GLOBAL.DEBUG='+d,block_applier_updates'; |
| 65 |
|
| 66 |
--echo # |
| 67 |
--echo # Step 2: Insert some transaction and remove server 3 |
| 68 |
--echo # |
| 69 |
|
| 70 |
--let $rpl_connection_name= server1 |
| 71 |
--source include/rpl_connection.inc |
| 72 |
|
| 73 |
INSERT INTO t1 VALUES (1); |
| 74 |
INSERT INTO t1 VALUES (2); |
| 75 |
|
| 76 |
--let $sync_slave_connection= server3 |
| 77 |
--source include/sync_slave_sql_with_master.inc |
| 78 |
|
| 79 |
--let $assert_text= Server 3 has 6 transaction belonging to the group |
| 80 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$group_replication_group_name:1-6"; |
| 81 |
--source include/assert.inc |
| 82 |
|
| 83 |
--source include/stop_group_replication.inc |
| 84 |
|
| 85 |
--echo # |
| 86 |
--echo # Step 3: Insert more transactions. |
| 87 |
--echo # Assert that server 2 applied none |
| 88 |
--echo # |
| 89 |
|
| 90 |
--let $rpl_connection_name= server1 |
| 91 |
--source include/rpl_connection.inc |
| 92 |
|
| 93 |
INSERT INTO t1 VALUES (3); |
| 94 |
INSERT INTO t1 VALUES (4); |
| 95 |
|
| 96 |
|
| 97 |
--let $rpl_connection_name= server2 |
| 98 |
--source include/rpl_connection.inc |
| 99 |
|
| 100 |
--let $wait_condition= SELECT received_transaction_set="$group_replication_group_name:1-8" FROM performance_schema.replication_connection_status WHERE channel_name='group_replication_applier'; |
| 101 |
--source include/wait_condition.inc |
| 102 |
|
| 103 |
--let $assert_text= Server 2 has only 4 applied transactions. |
| 104 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$group_replication_group_name:1-4"; |
| 105 |
--source include/assert.inc |
| 106 |
|
| 107 |
--echo # |
| 108 |
--echo # Step 4: Remove server 1 |
| 109 |
--echo # |
| 110 |
|
| 111 |
--let $rpl_connection_name= server1 |
| 112 |
--source include/rpl_connection.inc |
| 113 |
|
| 114 |
--source include/stop_group_replication.inc |
| 115 |
|
| 116 |
--echo # |
| 117 |
--echo # Step 5: Try add server 3 back to the group. |
| 118 |
--echo # Server 3 has more executed GTIDs, but server 2 has also retrieved GTIDs. |
| 119 |
--echo # |
| 120 |
|
| 121 |
--let $rpl_connection_name= server2 |
| 122 |
--source include/rpl_connection.inc |
| 123 |
|
| 124 |
--let $assert_text= Server 2 has only 4 applied transactions. |
| 125 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$group_replication_group_name:1-4"; |
| 126 |
--source include/assert.inc |
| 127 |
|
| 128 |
--let $rpl_connection_name= server3 |
| 129 |
--source include/rpl_connection.inc |
| 130 |
|
| 131 |
--let $assert_text= Server 3 has 6 applied transactions. |
| 132 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$group_replication_group_name:1-6"; |
| 133 |
--source include/assert.inc |
| 134 |
|
| 135 |
--eval SET GLOBAL group_replication_group_name= "$group_replication_group_name" |
| 136 |
--source include/start_group_replication_command.inc |
| 137 |
|
| 138 |
--echo # Resume server 2 applier |
| 139 |
|
| 140 |
--let $rpl_connection_name= server2 |
| 141 |
--source include/rpl_connection.inc |
| 142 |
|
| 143 |
SET DEBUG_SYNC = "now WAIT_FOR applier_read_blocked"; |
| 144 |
SET @@GLOBAL.DEBUG='-d,block_applier_updates'; |
| 145 |
SET DEBUG_SYNC = "now SIGNAL resume_applier_read"; |
| 146 |
|
| 147 |
--let $rpl_connection_name= server3 |
| 148 |
--source include/rpl_connection.inc |
| 149 |
|
| 150 |
--let $group_replication_member_state= ONLINE |
| 151 |
--source include/gr_wait_for_member_state.inc |
| 152 |
|
| 153 |
--echo # |
| 154 |
--echo # Step 6: Cleanup |
| 155 |
--echo # |
| 156 |
|
| 157 |
--let $rpl_connection_name= server2 |
| 158 |
--source include/rpl_connection.inc |
| 159 |
SET DEBUG_SYNC= 'RESET'; |
| 160 |
|
| 161 |
--let $rpl_connection_name= server1 |
| 162 |
--source include/rpl_connection.inc |
| 163 |
|
| 164 |
--source include/start_group_replication.inc |
| 165 |
|
| 166 |
DROP TABLE t1; |
| 167 |
|
| 168 |
--source include/group_replication_end.inc |