| 1 |
################################################################################ |
| 2 |
# This test verifies that during recovery the user cannot execute transactions |
| 3 |
# |
| 4 |
# We test: |
| 5 |
# 1. Single node recovery. |
| 6 |
# Block recovery with a debug sync point and check no queries can be applied. |
| 7 |
# 2. General replication. |
| 8 |
# Block recovery state transfer and check no queries can be applied. |
| 9 |
# |
| 10 |
# Test: |
| 11 |
# 0. The test requires two servers: M1 and M2. |
| 12 |
# Test local recovery: |
| 13 |
# 1. Bootstrap GR on the first node M1 after setting the debug point to block |
| 14 |
# recovery. Check transactions cannot be executed. |
| 15 |
# 2. Signal to unblock recovery. Check M1 is ONLINE. Table creation should pass |
| 16 |
# as M1 is ONLINE now. |
| 17 |
# Test for a joining member: |
| 18 |
# 3. Block state transfer by stoping applier thread on M1. Start GR on M2. |
| 19 |
# M2 should be in RECOVERING state. Check transactions cannot be executed. |
| 20 |
# 4. Unblock recovery on M2 by starting applier thread on M1. Table creation |
| 21 |
# should pass as this M2 has now recovered and in ONLINE state. |
| 22 |
# 5. Clean up. |
| 23 |
################################################################################ |
| 24 |
|
| 25 |
--source include/have_debug.inc |
| 26 |
--source include/have_debug_sync.inc |
| 27 |
--source include/have_group_replication_plugin.inc |
| 28 |
--let $rpl_skip_group_replication_start= 1 |
| 29 |
--source include/group_replication.inc |
| 30 |
|
| 31 |
--echo # |
| 32 |
--echo # 1. Test local recovery |
| 33 |
--echo # Start group_replication on the first node after setting the debug |
| 34 |
--echo # point to block recovery. Check whether transactions can be executed. |
| 35 |
--echo # |
| 36 |
|
| 37 |
--connection server1 |
| 38 |
SET @debug_save= @@GLOBAL.DEBUG; |
| 39 |
--echo # Set the debug flag to block recovery at different stages. |
| 40 |
SET @@GLOBAL.DEBUG='+d,recovery_thread_start_wait'; |
| 41 |
|
| 42 |
--source include/gr_set_bootstrap_group.inc |
| 43 |
|
| 44 |
--let $group_replication_start_member_state= RECOVERING |
| 45 |
--source include/start_group_replication.inc |
| 46 |
|
| 47 |
# Check we cannot execute transactions |
| 48 |
--connection server_1 |
| 49 |
--error ER_OPTION_PREVENTS_STATEMENT |
| 50 |
CREATE TABLE t1 (i INT NOT NULL PRIMARY KEY); |
| 51 |
|
| 52 |
#Unblock recovery |
| 53 |
SET DEBUG_SYNC= "now SIGNAL signal.recovery_continue"; |
| 54 |
|
| 55 |
--echo # Now wait for the node to be online |
| 56 |
--let $group_replication_member_state= ONLINE |
| 57 |
--source include/gr_wait_for_member_state.inc |
| 58 |
|
| 59 |
--echo # Table creation should pass as the single member is now recovered. |
| 60 |
CREATE TABLE t1 (i INT NOT NULL PRIMARY KEY); |
| 61 |
SET @@GLOBAL.DEBUG= @debug_save; |
| 62 |
|
| 63 |
--echo # |
| 64 |
--echo # 2. Test for a joining member |
| 65 |
--echo # Start group_replication on the second member and block state transfer |
| 66 |
--echo # Query execution should not be allowed |
| 67 |
--echo # |
| 68 |
|
| 69 |
--connection server1 |
| 70 |
SET @@GLOBAL.DEBUG='+d,block_applier_updates'; |
| 71 |
|
| 72 |
--connection server2 |
| 73 |
|
| 74 |
--let $group_replication_start_member_state= RECOVERING |
| 75 |
--source include/start_group_replication.inc |
| 76 |
|
| 77 |
--error ER_OPTION_PREVENTS_STATEMENT |
| 78 |
CREATE TABLE t2 (i INT NOT NULL PRIMARY KEY); |
| 79 |
|
| 80 |
# Unblock recovery and verify all is now normal |
| 81 |
--connection server1 |
| 82 |
SET DEBUG_SYNC = "now WAIT_FOR applier_read_blocked"; |
| 83 |
SET @@GLOBAL.DEBUG='-d,block_applier_updates'; |
| 84 |
SET DEBUG_SYNC = "now SIGNAL resume_applier_read"; |
| 85 |
|
| 86 |
--connection server2 |
| 87 |
--let $group_replication_member_state= ONLINE |
| 88 |
--source include/gr_wait_for_member_state.inc |
| 89 |
|
| 90 |
--echo # Table creation should pass as this node has now recovered. |
| 91 |
CREATE TABLE t2 (i INT NOT NULL PRIMARY KEY); |
| 92 |
|
| 93 |
--echo # |
| 94 |
--echo # Cleanup |
| 95 |
--echo # |
| 96 |
|
| 97 |
DROP TABLE t1; |
| 98 |
DROP TABLE t2; |
| 99 |
|
| 100 |
--connection server1 |
| 101 |
SET DEBUG_SYNC= 'RESET'; |
| 102 |
|
| 103 |
--source include/group_replication_end.inc |