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
|
################################################################################
# Validate that a single member goes through recovery process,
# consume existing applier relay log, even when it is the single
# member of the group.
#
# Test:
# 0. The test requires two servers.
# 1. Block SQL Threads on server2 so that all remote transactions are only queued
# on relay log. Execute some transactions on server1.
# 2. Wait until server2 receives and certifies the transaction.
# 3. Make both members leave the group.
# 4. Lock table on server2. Bootstrap start Group Replication only on server2.
# Validate that Member state is RECOVERING, despite being the only group
# member, since it is applying group applier relay log. Unlock tables. Wait
# until server2 comes ONLINE.
# 5. Assert that server1 and server2 have the same data and GTID_EXECUTED.
# 6. Clean up.
################################################################################
--source include/big_test.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc
--source include/have_group_replication_plugin.inc
--source include/group_replication.inc
--echo ############################################################
--echo # 1. Stop SQL Threads on server2 so that all remote transactions
--echo # are only queued on relay log. Execute some transactions on
--echo # server1.
--connection server1
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
--source include/rpl_sync.inc
--connection server2
SET @@GLOBAL.DEBUG='+d,block_applier_updates';
--connection server1
INSERT INTO t1 VALUES (1);
--echo
--echo ################################################################
--echo # 2. Wait until server2 receives and certifies the transaction.
--connection server2
--let $wait_condition= SELECT (Count_transactions_checked - Count_conflicts_detected) = 2 from performance_schema.replication_group_member_stats
--source include/wait_condition.inc
--echo
--echo ############################################################
--echo # 3. Make both members leave the group.
--connection server1
--source include/stop_group_replication.inc
--connection server2
# Do not commit the received transactions.
SET DEBUG_SYNC = "now WAIT_FOR applier_read_blocked";
SET @@GLOBAL.DEBUG='-d,block_applier_updates';
SET @@GLOBAL.DEBUG='+d,force_sql_thread_error';
SET DEBUG_SYNC = "now SIGNAL resume_applier_read";
--let $group_replication_member_state= ERROR
--source include/gr_wait_for_member_state.inc
SET @@GLOBAL.DEBUG='-d,force_sql_thread_error';
--source include/stop_group_replication.inc
SET DEBUG_SYNC= 'RESET';
--echo
--echo ############################################################
--echo # 4. Start Group Replication only on server2. Validate that
--echo # Member state is RECOVERING, despite being the only group
--echo # member, since it is applying group applier relay log.
# Force group applier relay log to wait on a table lock so that the
# next wait_for_member_state is deterministic.
--connection server_2
LOCK TABLE t1 WRITE;
--connection server2
--source include/gr_set_bootstrap_group.inc
SET @debug_save= @@GLOBAL.DEBUG;
SET GLOBAL debug= 'd,group_replication_skip_read_mode';
--let $group_replication_start_member_state= RECOVERING
--source include/start_group_replication.inc
--source include/gr_clear_bootstrap_group.inc
--connection server_2
UNLOCK TABLES;
--connection server2
--let $group_replication_member_state= ONLINE
--source include/gr_wait_for_member_state.inc
SET @@GLOBAL.DEBUG= @debug_save;
--echo
--echo ############################################################
--echo # 5. Assert that server1 and server2 have the same data and
--echo # GTID_EXECUTED.
--connection server1
--let $assert_text= 'There is a value 1 in table t1 on server1'
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 1
--source include/assert.inc
--connection server2
--let $assert_text= 'There is a value 1 in table t1 on server2'
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 1
--source include/assert.inc
--connection server2
--let $server2_gtid_executed= `SELECT @@GLOBAL.GTID_EXECUTED`
--let $assert_text= 'server2 GTID_EXECUTED must contain the 2 transactions plus 3 view changes'
--let $assert_cond= "$server2_gtid_executed" = "$group_replication_group_name:1-5"
--source include/assert.inc
--echo
--echo ############################################################
--echo # 6. Clean up.
--connection server1
--source include/start_group_replication.inc
DROP TABLE t1;
--connection server2
SET SESSION sql_log_bin = 0;
call mtr.add_suppression("Replica SQL for channel 'group_replication_applier': Relay log read failure: Could not parse relay log event entry.*");
call mtr.add_suppression("The applier thread execution was aborted. Unable to process more transactions, this member will now leave the group.");
call mtr.add_suppression("Fatal error during execution on the Applier process of Group Replication. The server will now leave the group.");
call mtr.add_suppression("The server was automatically set into read only mode after an error was detected.");
call mtr.add_suppression("Skipping leave operation: concurrent attempt to leave the group is on-going.");
SET SESSION sql_log_bin = 1;
--source include/group_replication_end.inc
|