| 1 |
############################################################################### |
| 2 |
# |
| 3 |
# If the action thread is killed but the configuration process |
| 4 |
# still has major tasks to complete the member will execute them and stay on |
| 5 |
# the group. |
| 6 |
# |
| 7 |
# Test: |
| 8 |
# 0. Group start in Multi Primary mode with 3 servers |
| 9 |
# 1. Get a transaction stuck on server 2 (the new primary) |
| 10 |
# 2. Do a change to single primary mode with server 2 as the new primary |
| 11 |
# Get the connection ID |
| 12 |
# See that it is stuck on Primary election |
| 13 |
# 3. Kill the query |
| 14 |
# 4. Resume transactions, it shall succeed and check the action |
| 15 |
# completed in the other members |
| 16 |
# 5. Cleanup |
| 17 |
# |
| 18 |
############################################################################### |
| 19 |
|
| 20 |
--source include/have_debug_sync.inc |
| 21 |
--source include/big_test.inc |
| 22 |
--source include/have_group_replication_plugin.inc |
| 23 |
--let $rpl_server_count= 3 |
| 24 |
--source include/group_replication.inc |
| 25 |
|
| 26 |
set session sql_log_bin=0; |
| 27 |
call mtr.add_suppression("The server was automatically set into read only mode after an error was detected."); |
| 28 |
call mtr.add_suppression("A configuration change was killed in this member. The member will now leave the group as its configuration may have diverged."); |
| 29 |
call mtr.add_suppression("Skipping leave operation: concurrent attempt to leave the group is on-going."); |
| 30 |
call mtr.add_suppression("The function 'group_replication_switch_to_single_primary_mode' failed. This operation was locally killed and for that reason terminated*"); |
| 31 |
set session sql_log_bin=1; |
| 32 |
|
| 33 |
--let $rpl_connection_name= server2 |
| 34 |
--source include/rpl_connection.inc |
| 35 |
|
| 36 |
--let $server2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 37 |
|
| 38 |
CREATE TABLE test.t1 (a INT PRIMARY KEY); |
| 39 |
--source include/rpl_sync.inc |
| 40 |
|
| 41 |
--echo |
| 42 |
--echo # 1. Get a transaction stuck on server 2 (the new primary) |
| 43 |
|
| 44 |
--let $rpl_connection_name= server_2 |
| 45 |
--source include/rpl_connection.inc |
| 46 |
|
| 47 |
--let $debug_point= group_replication_wait_on_observer_trans |
| 48 |
--source include/add_debug_point.inc |
| 49 |
|
| 50 |
--let $rpl_connection_name= server_1 |
| 51 |
--source include/rpl_connection.inc |
| 52 |
|
| 53 |
INSERT INTO t1 VALUES (1); |
| 54 |
|
| 55 |
--let $rpl_connection_name= server_2 |
| 56 |
--source include/rpl_connection.inc |
| 57 |
SET DEBUG_SYNC= "now WAIT_FOR signal.group_replication_wait_on_observer_trans_waiting"; |
| 58 |
|
| 59 |
--echo |
| 60 |
--echo # 2. Do a change to single primary mode with server 2 as the new primary |
| 61 |
--echo # Get the connection ID |
| 62 |
--echo # See that it is stuck on Primary election |
| 63 |
|
| 64 |
--let $rpl_connection_name= server1 |
| 65 |
--source include/rpl_connection.inc |
| 66 |
|
| 67 |
--let $conn_id=`SELECT CONNECTION_ID()` |
| 68 |
|
| 69 |
--replace_result $server2_uuid MEMBER2_UUID |
| 70 |
--send_eval SELECT group_replication_switch_to_single_primary_mode("$server2_uuid") |
| 71 |
|
| 72 |
--let $rpl_connection_name= server_1 |
| 73 |
--source include/rpl_connection.inc |
| 74 |
|
| 75 |
--let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "%Single-primary Switch: executing Primary%" and work_completed=1 |
| 76 |
--source include/wait_condition.inc |
| 77 |
|
| 78 |
--let $stage_name= `SELECT event_name FROM performance_schema.events_stages_current WHERE event_name LIKE "%Single-primary Switch:%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";` |
| 79 |
--let $assert_text= The stage should be "Single-primary Switch: executing Primary election" |
| 80 |
--let $assert_cond= "$stage_name" = "stage/group_rpl/Single-primary Switch: executing Primary election" |
| 81 |
--source include/assert.inc |
| 82 |
|
| 83 |
--let $rpl_connection_name= server3 |
| 84 |
--source include/rpl_connection.inc |
| 85 |
|
| 86 |
--let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "%Single-primary Switch: executing Primary%" and work_completed=1 |
| 87 |
--source include/wait_condition.inc |
| 88 |
|
| 89 |
--let $stage_name= `SELECT event_name FROM performance_schema.events_stages_current WHERE event_name LIKE "%Single-primary Switch:%";` |
| 90 |
--let $assert_text= The stage should be "Single-primary Switch: executing Primary election" |
| 91 |
--let $assert_cond= "$stage_name" = "stage/group_rpl/Single-primary Switch: executing Primary election" |
| 92 |
--source include/assert.inc |
| 93 |
|
| 94 |
--echo |
| 95 |
--echo # 3. Kill the query |
| 96 |
|
| 97 |
--let $rpl_connection_name= server_1 |
| 98 |
--source include/rpl_connection.inc |
| 99 |
|
| 100 |
--replace_result $conn_id CONNECTION_ID |
| 101 |
--eval KILL QUERY $conn_id |
| 102 |
|
| 103 |
--echo |
| 104 |
--echo # 4. Resume transactions, it shall succeed and check the action |
| 105 |
--echo # completed in the other members |
| 106 |
|
| 107 |
--let $rpl_connection_name= server_2 |
| 108 |
--source include/rpl_connection.inc |
| 109 |
|
| 110 |
--let $debug_point= group_replication_wait_on_observer_trans |
| 111 |
--source include/remove_debug_point.inc |
| 112 |
SET DEBUG_SYNC= 'now SIGNAL signal.group_replication_wait_on_observer_trans_continue'; |
| 113 |
|
| 114 |
--let $rpl_connection_name= server1 |
| 115 |
--source include/rpl_connection.inc |
| 116 |
|
| 117 |
--replace_result $server2_uuid MEMBER2_UUID |
| 118 |
--reap |
| 119 |
|
| 120 |
--let $rpl_connection_name= server_2 |
| 121 |
--source include/rpl_connection.inc |
| 122 |
|
| 123 |
--let $wait_condition=SELECT COUNT(*)=0 FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%" |
| 124 |
--source include/wait_condition.inc |
| 125 |
|
| 126 |
--source include/gr_assert_primary_member.inc |
| 127 |
|
| 128 |
SET DEBUG_SYNC='RESET'; |
| 129 |
|
| 130 |
--let $rpl_connection_name= server3 |
| 131 |
--source include/rpl_connection.inc |
| 132 |
|
| 133 |
--let $wait_condition=SELECT COUNT(*)=0 FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%" |
| 134 |
--source include/wait_condition.inc |
| 135 |
|
| 136 |
--source include/gr_assert_secondary_member.inc |
| 137 |
|
| 138 |
--let $rpl_connection_name= server1 |
| 139 |
--source include/rpl_connection.inc |
| 140 |
|
| 141 |
--let $wait_condition=SELECT COUNT(*)=0 FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%" |
| 142 |
--source include/wait_condition.inc |
| 143 |
|
| 144 |
--source include/gr_assert_secondary_member.inc |
| 145 |
|
| 146 |
--echo |
| 147 |
--echo # 5. Cleanup |
| 148 |
|
| 149 |
--let $rpl_connection_name= server2 |
| 150 |
--source include/rpl_connection.inc |
| 151 |
|
| 152 |
DROP TABLE t1; |
| 153 |
|
| 154 |
--let $rpl_group_replication_single_primary_mode=1 |
| 155 |
--let $rpl_group_replication_reset_persistent_vars=1 |
| 156 |
--source include/group_replication_end.inc |