| 1 |
############################################################################## |
| 2 |
# |
| 3 |
# All actions shall allow the DBA to check its progress. |
| 4 |
# |
| 5 |
# Also tested here: |
| 6 |
# Primary elections or change to multi-primary will be delayed |
| 7 |
# until all transactions forbidden by enforce_update_everywhere_checks |
| 8 |
# terminate. |
| 9 |
# |
| 10 |
# Test: |
| 11 |
# 0. 2 servers. Test starts in Single primary mode with server1 as the primary |
| 12 |
# |
| 13 |
# 1. Start 2 transactions on server 1 |
| 14 |
# Change to multi primary mode |
| 15 |
# On the primary the stage reports waiting for pending transactions to finish |
| 16 |
# Commit a transaction and see there is reported progress |
| 17 |
# On the secondaries the stage reports waiting for a step completion |
| 18 |
# 2. Lock table t1 on a secondary (server2) |
| 19 |
# Commit the last transaction on server1 |
| 20 |
# On the locked server the stage is: applying buffered transactions |
| 21 |
# 3. Block the stop process of the action using a debug point |
| 22 |
# Unlock the table on server 2 |
| 23 |
# Check it is stuck in the wait for other member to finish stage |
| 24 |
# 4. Unblock the debug point |
| 25 |
# Check the action terminates and no stages appear |
| 26 |
# 5. Cleanup |
| 27 |
# |
| 28 |
############################################################################## |
| 29 |
|
| 30 |
--source include/big_test.inc |
| 31 |
--source include/have_debug_sync.inc |
| 32 |
--source include/have_group_replication_plugin.inc |
| 33 |
--let $rpl_skip_group_replication_start= 1 |
| 34 |
--let $rpl_group_replication_single_primary_mode=1 |
| 35 |
--source include/group_replication.inc |
| 36 |
|
| 37 |
--echo |
| 38 |
--echo # 0. Test starts in Single primary mode with server1 as the primary |
| 39 |
|
| 40 |
--let $server1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 41 |
|
| 42 |
--source include/start_and_bootstrap_group_replication.inc |
| 43 |
|
| 44 |
--source include/gr_assert_primary_member.inc |
| 45 |
|
| 46 |
CREATE TABLE t1(a int primary key); |
| 47 |
|
| 48 |
--let $rpl_connection_name= server2 |
| 49 |
--source include/rpl_connection.inc |
| 50 |
--source include/start_group_replication.inc |
| 51 |
|
| 52 |
--echo |
| 53 |
--echo # 1. Start 2 transactions on server 1 |
| 54 |
--echo # Change to multi primary mode |
| 55 |
--echo # On the primary the stage reports waiting for pending transactions to finish |
| 56 |
--echo # Commit a transaction and see there is reported progress |
| 57 |
--echo # On the secondaries the stage reports waiting for a step completion |
| 58 |
|
| 59 |
--let $rpl_connection_name= server_1_1 |
| 60 |
--source include/rpl_connection.inc |
| 61 |
|
| 62 |
SET @@GLOBAL.DEBUG='+d,group_replication_before_message_broadcast'; |
| 63 |
BEGIN; |
| 64 |
INSERT INTO t1 VALUES (1); |
| 65 |
--send COMMIT |
| 66 |
|
| 67 |
--let $rpl_connection_name= server_1 |
| 68 |
--source include/rpl_connection.inc |
| 69 |
|
| 70 |
--let $wait_condition=SELECT COUNT(*)=1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE State = 'debug sync point: now' |
| 71 |
--source include/wait_condition.inc |
| 72 |
|
| 73 |
BEGIN; |
| 74 |
INSERT INTO t1 VALUES (2); |
| 75 |
|
| 76 |
--let $rpl_connection_name= server2 |
| 77 |
--source include/rpl_connection.inc |
| 78 |
|
| 79 |
--send SELECT group_replication_switch_to_multi_primary_mode() |
| 80 |
|
| 81 |
--let $rpl_connection_name= server1 |
| 82 |
--source include/rpl_connection.inc |
| 83 |
|
| 84 |
# Sleep so the select query is not included in the waiting numbers |
| 85 |
--sleep 2 |
| 86 |
|
| 87 |
--let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%" and work_estimated=2 |
| 88 |
--source include/wait_condition.inc |
| 89 |
|
| 90 |
--let $stage_name= `SELECT event_name FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";` |
| 91 |
--let $assert_text= The stage should be "Multi-primary Switch: waiting for pending transactions to finish" |
| 92 |
--let $assert_cond= "$stage_name" = "stage/group_rpl/Multi-primary Switch: waiting for pending transactions to finish" |
| 93 |
--source include/assert.inc |
| 94 |
|
| 95 |
--let $work_estimated= `SELECT work_estimated FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";` |
| 96 |
--let $assert_text= The estimated work is 2 |
| 97 |
--let $assert_cond= "$work_estimated" = "2" |
| 98 |
--source include/assert.inc |
| 99 |
|
| 100 |
--let $work_completed= `SELECT work_completed FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";` |
| 101 |
--let $assert_text= The completed work is 0 |
| 102 |
--let $assert_cond= "$work_completed" = "0" |
| 103 |
--source include/assert.inc |
| 104 |
|
| 105 |
--let $rpl_connection_name= server_2 |
| 106 |
--source include/rpl_connection.inc |
| 107 |
|
| 108 |
--let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%" |
| 109 |
--source include/wait_condition.inc |
| 110 |
|
| 111 |
--let $stage_name= `SELECT event_name FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";` |
| 112 |
--let $assert_text= The stage should be "Multi-primary Switch: waiting on another member step completion" |
| 113 |
--let $assert_cond= "$stage_name" = "stage/group_rpl/Multi-primary Switch: waiting on another member step completion" |
| 114 |
--source include/assert.inc |
| 115 |
|
| 116 |
--let $work_estimated= `SELECT work_estimated FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";` |
| 117 |
--let $assert_text= The estimated work is 1 |
| 118 |
--let $assert_cond= "$work_estimated" = "1" |
| 119 |
--source include/assert.inc |
| 120 |
|
| 121 |
--let $work_completed= `SELECT work_completed FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";` |
| 122 |
--let $assert_text= The completed work is 0 |
| 123 |
--let $assert_cond= "$work_completed" = "0" |
| 124 |
--source include/assert.inc |
| 125 |
|
| 126 |
--let $rpl_connection_name= server1 |
| 127 |
--source include/rpl_connection.inc |
| 128 |
|
| 129 |
SET DEBUG_SYNC='now SIGNAL waiting'; |
| 130 |
SET @@GLOBAL.DEBUG='-d,group_replication_before_message_broadcast'; |
| 131 |
|
| 132 |
--let $rpl_connection_name= server_1_1 |
| 133 |
--source include/rpl_connection.inc |
| 134 |
|
| 135 |
--reap; |
| 136 |
|
| 137 |
--let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%" and work_completed=1 |
| 138 |
--source include/wait_condition.inc |
| 139 |
|
| 140 |
--let $stage_name= `SELECT event_name FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";` |
| 141 |
--let $assert_text= The stage should be "Multi-primary Switch: waiting for pending transactions to finish" |
| 142 |
--let $assert_cond= "$stage_name" = "stage/group_rpl/Multi-primary Switch: waiting for pending transactions to finish" |
| 143 |
--source include/assert.inc |
| 144 |
|
| 145 |
--let $work_estimated= `SELECT work_estimated FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";` |
| 146 |
--let $assert_text= The estimated work is 2 |
| 147 |
--let $assert_cond= "$work_estimated" = "2" |
| 148 |
--source include/assert.inc |
| 149 |
|
| 150 |
--let $work_completed= `SELECT work_completed FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";` |
| 151 |
--let $assert_text= The completed work is 1 |
| 152 |
--let $assert_cond= "$work_completed" = "1" |
| 153 |
--source include/assert.inc |
| 154 |
|
| 155 |
--echo |
| 156 |
--echo # 2. Lock table t1 on a secondary (server2) |
| 157 |
--echo # Commit the last transaction on server1 |
| 158 |
--echo # On the locked server the stage is: applying buffered transactions |
| 159 |
|
| 160 |
--let $rpl_connection_name= server_2_1 |
| 161 |
--source include/rpl_connection.inc |
| 162 |
|
| 163 |
SET @@GLOBAL.read_only= 0; |
| 164 |
LOCK TABLE t1 READ; |
| 165 |
|
| 166 |
--let $rpl_connection_name= server_1 |
| 167 |
--source include/rpl_connection.inc |
| 168 |
|
| 169 |
COMMIT; |
| 170 |
|
| 171 |
--let $rpl_connection_name= server_2 |
| 172 |
--source include/rpl_connection.inc |
| 173 |
|
| 174 |
--let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "%Multi-primary Switch: applying buffered %" |
| 175 |
--source include/wait_condition.inc |
| 176 |
|
| 177 |
--let $stage_name= `SELECT event_name FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";` |
| 178 |
--let $assert_text= The stage should be "Multi-primary Switch: applying buffered transactions" |
| 179 |
--let $assert_cond= "$stage_name" = "stage/group_rpl/Multi-primary Switch: applying buffered transactions" |
| 180 |
--source include/assert.inc |
| 181 |
|
| 182 |
--let $work_estimated= `SELECT work_estimated FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";` |
| 183 |
--let $assert_text= The estimated work is 1 |
| 184 |
--let $assert_cond= "$work_estimated" = "1" |
| 185 |
--source include/assert.inc |
| 186 |
|
| 187 |
--let $work_completed= `SELECT work_completed FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";` |
| 188 |
--let $assert_text= The completed work is 0 |
| 189 |
--let $assert_cond= "$work_completed" = "0" |
| 190 |
--source include/assert.inc |
| 191 |
|
| 192 |
|
| 193 |
--echo |
| 194 |
--echo # 3. Block the stop process of the action using a debug point |
| 195 |
--echo # Unlock the table on server 2 |
| 196 |
--echo # Check it is stuck in the wait for other member to finish stage |
| 197 |
|
| 198 |
SET @@GLOBAL.DEBUG= '+d,group_replication_block_group_action_stop'; |
| 199 |
|
| 200 |
--let $rpl_connection_name= server_2_1 |
| 201 |
--source include/rpl_connection.inc |
| 202 |
|
| 203 |
UNLOCK TABLES; |
| 204 |
|
| 205 |
--let $rpl_connection_name= server1 |
| 206 |
--source include/rpl_connection.inc |
| 207 |
|
| 208 |
--let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "%Multi-primary Switch: waiting for%" and work_completed=1 |
| 209 |
--source include/wait_condition.inc |
| 210 |
|
| 211 |
--let $stage_name= `SELECT event_name FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";` |
| 212 |
--let $assert_text= The stage should be "Multi-primary Switch: waiting for operation to complete on all members" |
| 213 |
--let $assert_cond= "$stage_name" = "stage/group_rpl/Multi-primary Switch: waiting for operation to complete on all members" |
| 214 |
--source include/assert.inc |
| 215 |
|
| 216 |
--let $work_estimated= `SELECT work_estimated FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";` |
| 217 |
--let $assert_text= The estimated work is 2 |
| 218 |
--let $assert_cond= "$work_estimated" = "2" |
| 219 |
--source include/assert.inc |
| 220 |
|
| 221 |
--let $work_completed= `SELECT work_completed FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";` |
| 222 |
--let $assert_text= The completed work is 1 |
| 223 |
--let $assert_cond= "$work_completed" = "1" |
| 224 |
--source include/assert.inc |
| 225 |
|
| 226 |
--let $rpl_connection_name= server_2 |
| 227 |
--source include/rpl_connection.inc |
| 228 |
|
| 229 |
--let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "%Multi-primary Switch: waiting for%" and work_completed=1 |
| 230 |
--source include/wait_condition.inc |
| 231 |
|
| 232 |
--let $stage_name= `SELECT event_name FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";` |
| 233 |
--let $assert_text= The stage should be "Multi-primary Switch: waiting for operation to complete on all members" |
| 234 |
--let $assert_cond= "$stage_name" = "stage/group_rpl/Multi-primary Switch: waiting for operation to complete on all members" |
| 235 |
--source include/assert.inc |
| 236 |
|
| 237 |
--let $work_estimated= `SELECT work_estimated FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";` |
| 238 |
--let $assert_text= The estimated work is 2 |
| 239 |
--let $assert_cond= "$work_estimated" = "2" |
| 240 |
--source include/assert.inc |
| 241 |
|
| 242 |
--let $work_completed= `SELECT work_completed FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";` |
| 243 |
--let $assert_text= The completed work is 1 |
| 244 |
--let $assert_cond= "$work_completed" = "1" |
| 245 |
--source include/assert.inc |
| 246 |
|
| 247 |
--echo |
| 248 |
--echo # 4. Unblock the debug point |
| 249 |
--echo # Check the action terminates and no stages appear |
| 250 |
|
| 251 |
SET DEBUG_SYNC= "now SIGNAL signal.action_stop_continue"; |
| 252 |
SET @@GLOBAL.DEBUG= '-d,group_replication_block_group_action_stop'; |
| 253 |
|
| 254 |
--let $rpl_connection_name= server2 |
| 255 |
--source include/rpl_connection.inc |
| 256 |
|
| 257 |
--reap |
| 258 |
|
| 259 |
#Stages sometimes linger for a brief time after the action terminated |
| 260 |
--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%" |
| 261 |
--source include/wait_condition.inc |
| 262 |
|
| 263 |
--let $stages_present= `SELECT COUNT(*) FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";` |
| 264 |
--let $assert_text= There is no stage present |
| 265 |
--let $assert_cond= "$stages_present" = "0" |
| 266 |
--source include/assert.inc |
| 267 |
|
| 268 |
--let $rpl_connection_name= server1 |
| 269 |
--source include/rpl_connection.inc |
| 270 |
|
| 271 |
--let $stages_present= `SELECT COUNT(*) FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";` |
| 272 |
--let $assert_text= There is no stage present |
| 273 |
--let $assert_cond= "$stages_present" = "0" |
| 274 |
--source include/assert.inc |
| 275 |
|
| 276 |
--echo |
| 277 |
--echo # 5. Cleanup |
| 278 |
|
| 279 |
DROP TABLE t1; |
| 280 |
|
| 281 |
--let $rpl_group_replication_single_primary_mode=0 |
| 282 |
--let $rpl_group_replication_reset_persistent_vars=1 |
| 283 |
--source include/group_replication_end.inc |