| 1 |
################################################################################ |
| 2 |
# Validate that a single member goes through recovery process, |
| 3 |
# consume existing applier relay log, even when it is the single |
| 4 |
# member of the group. |
| 5 |
# |
| 6 |
# Test: |
| 7 |
# 0. The test requires two servers. |
| 8 |
# 1. Block SQL Threads on server2 so that all remote transactions are only queued |
| 9 |
# on relay log. Execute some transactions on server1. |
| 10 |
# 2. Wait until server2 receives and certifies the transaction. |
| 11 |
# 3. Make both members leave the group. |
| 12 |
# 4. Lock table on server2. Bootstrap start Group Replication only on server2. |
| 13 |
# Validate that Member state is RECOVERING, despite being the only group |
| 14 |
# member, since it is applying group applier relay log. Unlock tables. Wait |
| 15 |
# until server2 comes ONLINE. |
| 16 |
# 5. Assert that server1 and server2 have the same data and GTID_EXECUTED. |
| 17 |
# 6. Clean up. |
| 18 |
################################################################################ |
| 19 |
--source include/big_test.inc |
| 20 |
--source include/have_debug.inc |
| 21 |
--source include/have_debug_sync.inc |
| 22 |
--source include/have_group_replication_plugin.inc |
| 23 |
--source include/group_replication.inc |
| 24 |
|
| 25 |
|
| 26 |
--echo ############################################################ |
| 27 |
--echo # 1. Stop SQL Threads on server2 so that all remote transactions |
| 28 |
--echo # are only queued on relay log. Execute some transactions on |
| 29 |
--echo # server1. |
| 30 |
--connection server1 |
| 31 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 32 |
--source include/rpl_sync.inc |
| 33 |
|
| 34 |
--connection server2 |
| 35 |
SET @@GLOBAL.DEBUG='+d,block_applier_updates'; |
| 36 |
|
| 37 |
--connection server1 |
| 38 |
INSERT INTO t1 VALUES (1); |
| 39 |
|
| 40 |
|
| 41 |
--echo |
| 42 |
--echo ################################################################ |
| 43 |
--echo # 2. Wait until server2 receives and certifies the transaction. |
| 44 |
--connection server2 |
| 45 |
--let $wait_condition= SELECT (Count_transactions_checked - Count_conflicts_detected) = 2 from performance_schema.replication_group_member_stats |
| 46 |
--source include/wait_condition.inc |
| 47 |
|
| 48 |
--echo |
| 49 |
--echo ############################################################ |
| 50 |
--echo # 3. Make both members leave the group. |
| 51 |
--connection server1 |
| 52 |
--source include/stop_group_replication.inc |
| 53 |
--connection server2 |
| 54 |
# Do not commit the received transactions. |
| 55 |
SET DEBUG_SYNC = "now WAIT_FOR applier_read_blocked"; |
| 56 |
SET @@GLOBAL.DEBUG='-d,block_applier_updates'; |
| 57 |
SET @@GLOBAL.DEBUG='+d,force_sql_thread_error'; |
| 58 |
SET DEBUG_SYNC = "now SIGNAL resume_applier_read"; |
| 59 |
--let $group_replication_member_state= ERROR |
| 60 |
--source include/gr_wait_for_member_state.inc |
| 61 |
SET @@GLOBAL.DEBUG='-d,force_sql_thread_error'; |
| 62 |
--source include/stop_group_replication.inc |
| 63 |
SET DEBUG_SYNC= 'RESET'; |
| 64 |
|
| 65 |
|
| 66 |
--echo |
| 67 |
--echo ############################################################ |
| 68 |
--echo # 4. Start Group Replication only on server2. Validate that |
| 69 |
--echo # Member state is RECOVERING, despite being the only group |
| 70 |
--echo # member, since it is applying group applier relay log. |
| 71 |
# Force group applier relay log to wait on a table lock so that the |
| 72 |
# next wait_for_member_state is deterministic. |
| 73 |
--connection server_2 |
| 74 |
LOCK TABLE t1 WRITE; |
| 75 |
|
| 76 |
--connection server2 |
| 77 |
--source include/gr_set_bootstrap_group.inc |
| 78 |
|
| 79 |
SET @debug_save= @@GLOBAL.DEBUG; |
| 80 |
SET GLOBAL debug= 'd,group_replication_skip_read_mode'; |
| 81 |
|
| 82 |
--let $group_replication_start_member_state= RECOVERING |
| 83 |
--source include/start_group_replication.inc |
| 84 |
|
| 85 |
--source include/gr_clear_bootstrap_group.inc |
| 86 |
|
| 87 |
--connection server_2 |
| 88 |
UNLOCK TABLES; |
| 89 |
|
| 90 |
--connection server2 |
| 91 |
--let $group_replication_member_state= ONLINE |
| 92 |
--source include/gr_wait_for_member_state.inc |
| 93 |
|
| 94 |
SET @@GLOBAL.DEBUG= @debug_save; |
| 95 |
|
| 96 |
--echo |
| 97 |
--echo ############################################################ |
| 98 |
--echo # 5. Assert that server1 and server2 have the same data and |
| 99 |
--echo # GTID_EXECUTED. |
| 100 |
--connection server1 |
| 101 |
--let $assert_text= 'There is a value 1 in table t1 on server1' |
| 102 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 1 |
| 103 |
--source include/assert.inc |
| 104 |
|
| 105 |
--connection server2 |
| 106 |
--let $assert_text= 'There is a value 1 in table t1 on server2' |
| 107 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 1 |
| 108 |
--source include/assert.inc |
| 109 |
|
| 110 |
--connection server2 |
| 111 |
--let $server2_gtid_executed= `SELECT @@GLOBAL.GTID_EXECUTED` |
| 112 |
--let $assert_text= 'server2 GTID_EXECUTED must contain the 2 transactions plus 3 view changes' |
| 113 |
--let $assert_cond= "$server2_gtid_executed" = "$group_replication_group_name:1-5" |
| 114 |
--source include/assert.inc |
| 115 |
|
| 116 |
|
| 117 |
--echo |
| 118 |
--echo ############################################################ |
| 119 |
--echo # 6. Clean up. |
| 120 |
--connection server1 |
| 121 |
--source include/start_group_replication.inc |
| 122 |
|
| 123 |
DROP TABLE t1; |
| 124 |
|
| 125 |
--connection server2 |
| 126 |
SET SESSION sql_log_bin = 0; |
| 127 |
call mtr.add_suppression("Replica SQL for channel 'group_replication_applier': Relay log read failure: Could not parse relay log event entry.*"); |
| 128 |
call mtr.add_suppression("The applier thread execution was aborted. Unable to process more transactions, this member will now leave the group."); |
| 129 |
call mtr.add_suppression("Fatal error during execution on the Applier process of Group Replication. The server will now leave the group."); |
| 130 |
call mtr.add_suppression("The server was automatically set into read only mode after an error was detected."); |
| 131 |
call mtr.add_suppression("Skipping leave operation: concurrent attempt to leave the group is on-going."); |
| 132 |
SET SESSION sql_log_bin = 1; |
| 133 |
|
| 134 |
--source include/group_replication_end.inc |