| 1 |
################################################################################ |
| 2 |
# This test validates operations on different stages of completion of timeout |
| 3 |
# parameter of UDF group_replication_set_as_primary(). |
| 4 |
# |
| 5 |
# Test: |
| 6 |
# 0. This test requires 2 servers. |
| 7 |
# 1. Start group in single primary mode. |
| 8 |
# Server1 will be primary and server 2 secondary. |
| 9 |
# 2. Block a transaction on server1. |
| 10 |
# Initiate primary change from server2(secondary) with running_transactions_timeout value as 30. |
| 11 |
# Unblock server1 transactions. |
| 12 |
# Since there is no transaction now, THD_transaction_monitor allow all transactions. |
| 13 |
# Primary change operations finishes and THD_transaction_monitor finishes. |
| 14 |
# 3. Block a transaction on server2. |
| 15 |
# Initiate primary change from server2(primary) with running_transactions_timeout value as 30. |
| 16 |
# Unblock server2 transactions. |
| 17 |
# Since there is no transaction now, THD_transaction_monitor allow all transactions. |
| 18 |
# Primary change operations finishes and THD_transaction_monitor finishes. |
| 19 |
# 4. Cleanup. |
| 20 |
################################################################################ |
| 21 |
|
| 22 |
# big test due to 30 seconds timer present in UDF group_replication_set_as_primary |
| 23 |
--source include/big_test.inc |
| 24 |
--source include/not_valgrind.inc |
| 25 |
--source include/not_valgrind_server.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 |
--let $rpl_group_replication_single_primary_mode=1 |
| 30 |
--source include/group_replication.inc |
| 31 |
|
| 32 |
--echo |
| 33 |
--echo # 1. Start group in single primary mode. |
| 34 |
--echo # Server1 will be primary and server 2 secondary. |
| 35 |
|
| 36 |
--let $rpl_connection_name= server1 |
| 37 |
--source include/rpl_connection.inc |
| 38 |
|
| 39 |
--let $server1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 40 |
CREATE TABLE t1 (c1 int primary key); |
| 41 |
--source include/start_and_bootstrap_group_replication.inc |
| 42 |
|
| 43 |
--let $rpl_connection_name= server2 |
| 44 |
--source include/rpl_connection.inc |
| 45 |
|
| 46 |
--let $server2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 47 |
--source include/start_group_replication.inc |
| 48 |
|
| 49 |
--echo |
| 50 |
--echo # 2. Block a transaction on server1. |
| 51 |
--echo # Initiate primary change from server2(secondary) with running_transactions_timeout value as 30. |
| 52 |
--echo # Unblock server1 transactions. |
| 53 |
--echo # Since there is no transaction now, THD_transaction_monitor allow all transactions. |
| 54 |
--echo # Primary change operations finishes and THD_transaction_monitor finishes. |
| 55 |
|
| 56 |
--let $rpl_connection_name= server1 |
| 57 |
--source include/rpl_connection.inc |
| 58 |
|
| 59 |
SET @@GLOBAL.DEBUG= '+d,group_replication_before_commit_hook_wait'; |
| 60 |
SET @@GLOBAL.DEBUG= '+d,group_replication_transaction_monitor_end'; |
| 61 |
--send INSERT INTO t1 values(1) |
| 62 |
|
| 63 |
--let $rpl_connection_name= server_1 |
| 64 |
--source include/rpl_connection.inc |
| 65 |
|
| 66 |
SET DEBUG_SYNC= "now WAIT_FOR signal.group_replication_before_commit_hook_wait_reached"; |
| 67 |
|
| 68 |
--let $rpl_connection_name= server2 |
| 69 |
--source include/rpl_connection.inc |
| 70 |
|
| 71 |
--replace_result $server2_uuid SERVER2_UUID |
| 72 |
--send_eval SELECT group_replication_set_as_primary("$server2_uuid", 30); |
| 73 |
|
| 74 |
--let $rpl_connection_name= server_1 |
| 75 |
--source include/rpl_connection.inc |
| 76 |
|
| 77 |
# verify thread THD_group_action_coordinator has started |
| 78 |
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.threads WHERE NAME = "thread/group_rpl/THD_transaction_monitor" |
| 79 |
--source include/wait_condition_or_abort.inc |
| 80 |
|
| 81 |
# New transactions have been stopped immediately |
| 82 |
--let $assert_text= Transaction monitor thread is in block state in < 30 seconds. |
| 83 |
--let $assert_cond= "[select COUNT(*) FROM performance_schema.threads where NAME=\"thread/group_rpl/THD_transaction_monitor\" and PROCESSLIST_INFO = "Group replication transaction monitor: Stopped new transactions"]" = 1; |
| 84 |
--source include/assert.inc |
| 85 |
|
| 86 |
--let $assert_text= The super_read_only mode should be 0 here. |
| 87 |
--let $assert_cond= "[SELECT @@GLOBAL.super_read_only]" = 0; |
| 88 |
--source include/assert.inc |
| 89 |
|
| 90 |
# Since 30 seconds have elapsed clients running binloggable transactions that did not reach commit have been disconnected. |
| 91 |
|
| 92 |
--let $wait_timeout=60 |
| 93 |
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.threads WHERE NAME = "thread/group_rpl/THD_transaction_monitor" AND PROCESSLIST_INFO = "Group replication transaction monitor: Stopped client connections" |
| 94 |
--source include/wait_condition_or_abort.inc |
| 95 |
|
| 96 |
--let $assert_text= The super_read_only mode should be 0 here. |
| 97 |
--let $assert_cond= "[SELECT @@GLOBAL.super_read_only]" = 0; |
| 98 |
--source include/assert.inc |
| 99 |
|
| 100 |
# Again sleep to prove operation is still blocked |
| 101 |
--sleep 5 |
| 102 |
|
| 103 |
--let $assert_text= Transaction monitor thread has disconnected the client connections. |
| 104 |
--let $assert_cond= "[select COUNT(*) FROM performance_schema.threads where NAME=\"thread/group_rpl/THD_transaction_monitor\" and PROCESSLIST_INFO = "Group replication transaction monitor: Stopped client connections"]" = 1; |
| 105 |
--source include/assert.inc |
| 106 |
|
| 107 |
SET DEBUG_SYNC= "now SIGNAL continue_commit"; |
| 108 |
|
| 109 |
# Confirm transactions are allowed at time of finish of operation and read_only mode is set for safety. |
| 110 |
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.threads WHERE NAME = "thread/group_rpl/THD_transaction_monitor" AND PROCESSLIST_INFO = "Group replication transaction monitor: Allowing new transactions" |
| 111 |
--source include/wait_condition_or_abort.inc |
| 112 |
|
| 113 |
--let $assert_text= The super_read_only mode should be 1 here. |
| 114 |
--let $assert_cond= "[SELECT @@GLOBAL.super_read_only]" = 1; |
| 115 |
--source include/assert.inc |
| 116 |
|
| 117 |
SET DEBUG_SYNC= "now SIGNAL signal.group_replication_wait_on_transaction_monitor_end"; |
| 118 |
|
| 119 |
SET @@GLOBAL.DEBUG= '-d,group_replication_before_commit_hook_wait'; |
| 120 |
SET @@GLOBAL.DEBUG= '-d,group_replication_transaction_monitor_end'; |
| 121 |
|
| 122 |
--let $rpl_connection_name= server1 |
| 123 |
--source include/rpl_connection.inc |
| 124 |
--reap |
| 125 |
|
| 126 |
--let $rpl_connection_name= server2 |
| 127 |
--source include/rpl_connection.inc |
| 128 |
--replace_result $server2_uuid SERVER2_UUID |
| 129 |
--reap |
| 130 |
|
| 131 |
# Transactions that have reached the commit stage are not rollback. |
| 132 |
--let $assert_text= 'There is a value 1 in table t1' |
| 133 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 1 |
| 134 |
--source include/assert.inc |
| 135 |
|
| 136 |
--echo |
| 137 |
--echo # 3. Block a transaction on server2. |
| 138 |
--echo # Initiate primary change from server2(primary) with running_transactions_timeout value as 30. |
| 139 |
--echo # Unblock server2 transactions. |
| 140 |
--echo # Since there is no transaction now, THD_transaction_monitor allow all transactions. |
| 141 |
--echo # Primary change operations finishes and THD_transaction_monitor finishes. |
| 142 |
|
| 143 |
--let $rpl_connection_name= server2 |
| 144 |
--source include/rpl_connection.inc |
| 145 |
|
| 146 |
SET @@GLOBAL.DEBUG= '+d,group_replication_before_commit_hook_wait'; |
| 147 |
SET @@GLOBAL.DEBUG= '+d,group_replication_transaction_monitor_end'; |
| 148 |
--send INSERT INTO t1 values(2) |
| 149 |
|
| 150 |
--let $rpl_connection_name= server_2 |
| 151 |
--source include/rpl_connection.inc |
| 152 |
|
| 153 |
SET DEBUG_SYNC= "now WAIT_FOR signal.group_replication_before_commit_hook_wait_reached"; |
| 154 |
|
| 155 |
--let $rpl_connection_name= server_2_1 |
| 156 |
--source include/rpl_connection.inc |
| 157 |
|
| 158 |
--replace_result $server1_uuid SERVER1_UUID |
| 159 |
--send_eval SELECT group_replication_set_as_primary("$server1_uuid", 30); |
| 160 |
|
| 161 |
--let $rpl_connection_name= server_2 |
| 162 |
--source include/rpl_connection.inc |
| 163 |
|
| 164 |
# verify thread THD_group_action_coordinator has started |
| 165 |
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.threads WHERE NAME = "thread/group_rpl/THD_transaction_monitor" |
| 166 |
--source include/wait_condition_or_abort.inc |
| 167 |
|
| 168 |
--let $assert_text= Transaction monitor thread is in block state in < 30 seconds. |
| 169 |
--let $assert_cond= "[select COUNT(*) FROM performance_schema.threads where NAME=\"thread/group_rpl/THD_transaction_monitor\" and PROCESSLIST_INFO = "Group replication transaction monitor: Stopped new transactions"]" = 1; |
| 170 |
--source include/assert.inc |
| 171 |
|
| 172 |
--let $assert_text= The super_read_only mode should be 0 here. |
| 173 |
--let $assert_cond= "[SELECT @@GLOBAL.super_read_only]" = 0; |
| 174 |
--source include/assert.inc |
| 175 |
|
| 176 |
--let $wait_timeout=60 |
| 177 |
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.threads WHERE NAME = "thread/group_rpl/THD_transaction_monitor" AND PROCESSLIST_INFO = "Group replication transaction monitor: Stopped client connections" |
| 178 |
--source include/wait_condition_or_abort.inc |
| 179 |
|
| 180 |
--let $assert_text= The super_read_only mode should be 0 here. |
| 181 |
--let $assert_cond= "[SELECT @@GLOBAL.super_read_only]" = 0; |
| 182 |
--source include/assert.inc |
| 183 |
|
| 184 |
# Again sleep to prove operation is still blocked |
| 185 |
--sleep 5 |
| 186 |
|
| 187 |
--let $assert_text= Transaction monitor thread has disconnected the client connections. |
| 188 |
--let $assert_cond= "[select COUNT(*) FROM performance_schema.threads where NAME=\"thread/group_rpl/THD_transaction_monitor\" and PROCESSLIST_INFO = "Group replication transaction monitor: Stopped client connections"]" = 1; |
| 189 |
--source include/assert.inc |
| 190 |
|
| 191 |
SET DEBUG_SYNC= "now SIGNAL continue_commit"; |
| 192 |
|
| 193 |
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.threads WHERE NAME = "thread/group_rpl/THD_transaction_monitor" AND PROCESSLIST_INFO = "Group replication transaction monitor: Allowing new transactions" |
| 194 |
--source include/wait_condition.inc |
| 195 |
|
| 196 |
--let $assert_text= The super_read_only mode should be 1 here. |
| 197 |
--let $assert_cond= "[SELECT @@GLOBAL.super_read_only]" = 1; |
| 198 |
--source include/assert.inc |
| 199 |
|
| 200 |
SET DEBUG_SYNC= "now SIGNAL signal.group_replication_wait_on_transaction_monitor_end"; |
| 201 |
|
| 202 |
SET @@GLOBAL.DEBUG= '-d,group_replication_before_commit_hook_wait'; |
| 203 |
SET @@GLOBAL.DEBUG= '-d,group_replication_transaction_monitor_end'; |
| 204 |
|
| 205 |
--let $rpl_connection_name= server2 |
| 206 |
--source include/rpl_connection.inc |
| 207 |
--reap |
| 208 |
|
| 209 |
# Transactions that have reached the commit stage are not rollback. |
| 210 |
--let $assert_text= 'There is a value 2 in table t1' |
| 211 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 2, count, 1] = 1 |
| 212 |
--source include/assert.inc |
| 213 |
|
| 214 |
--let $rpl_connection_name= server_2_1 |
| 215 |
--source include/rpl_connection.inc |
| 216 |
--replace_result $server1_uuid SERVER1_UUID |
| 217 |
--reap |
| 218 |
|
| 219 |
--echo |
| 220 |
--echo # 4. Cleanup. |
| 221 |
|
| 222 |
--let $rpl_connection_name= server1 |
| 223 |
--source include/rpl_connection.inc |
| 224 |
DROP TABLE t1; |
| 225 |
|
| 226 |
--source include/group_replication_end.inc |