| 1 |
# Usage: |
| 2 |
# |
| 3 |
# [--let $rpl_test_optimize_for_static_plugin_config = 1|0] |
| 4 |
# --source suite/rpl/t/rpl_semi_sync.test |
| 5 |
# |
| 6 |
# Parameters: |
| 7 |
# |
| 8 |
# $rpl_test_optimize_for_static_plugin_config |
| 9 |
# When set to `1`, will run the contained test-cases with |
| 10 |
# `replication_optimize_for_static_plugin_config` option enabled. |
| 11 |
# |
| 12 |
|
| 13 |
# Want to skip this test from daily Valgrind execution |
| 14 |
--source include/no_valgrind_without_big.inc |
| 15 |
# Adding big test option for this test. |
| 16 |
--source include/big_test.inc |
| 17 |
|
| 18 |
source include/have_semisync_plugin.inc; |
| 19 |
source include/master-slave.inc; |
| 20 |
|
| 21 |
let $engine_type= InnoDB; |
| 22 |
|
| 23 |
# Suppress warnings that might be generated during the test |
| 24 |
connection master; |
| 25 |
disable_query_log; |
| 26 |
call mtr.add_suppression("Timeout waiting for reply of binlog"); |
| 27 |
call mtr.add_suppression("Read semi-sync reply"); |
| 28 |
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT."); |
| 29 |
call mtr.add_suppression("Semi-sync source failed on net_flush.. before waiting for replica reply"); |
| 30 |
call mtr.add_suppression("Source server does not support semi-sync"); |
| 31 |
call mtr.add_suppression("Semi-sync replica .* reply"); |
| 32 |
call mtr.add_suppression("Replica SQL.*Request to stop replica SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group"); |
| 33 |
call mtr.add_suppression(".*Got an error reading communication packets.*"); |
| 34 |
enable_query_log; |
| 35 |
--source include/sync_slave_sql_with_master.inc |
| 36 |
|
| 37 |
# After fix of BUG#45848, semi-sync slave should not create any extra |
| 38 |
# connections on master, save the count of connections before start |
| 39 |
# semi-sync slave for comparison below. |
| 40 |
connection master; |
| 41 |
let $_connections_normal_slave= query_get_value(SHOW STATUS LIKE 'Threads_connected', Value, 1); |
| 42 |
|
| 43 |
--echo # |
| 44 |
--echo # Uninstall semi-sync plugins on master and slave |
| 45 |
--echo # |
| 46 |
connection slave; |
| 47 |
source include/stop_slave.inc; |
| 48 |
disable_warnings; |
| 49 |
error 0,1305; |
| 50 |
UNINSTALL PLUGIN rpl_semi_sync_replica; |
| 51 |
error 0,1305; |
| 52 |
UNINSTALL PLUGIN rpl_semi_sync_source; |
| 53 |
enable_warnings; |
| 54 |
|
| 55 |
connection master; |
| 56 |
disable_warnings; |
| 57 |
error 0,1305; |
| 58 |
UNINSTALL PLUGIN rpl_semi_sync_replica; |
| 59 |
error 0,1305; |
| 60 |
UNINSTALL PLUGIN rpl_semi_sync_source; |
| 61 |
enable_warnings; |
| 62 |
--let $rpl_only_running_threads= 1 |
| 63 |
--let $rpl_no_start_slave= 1 |
| 64 |
--source include/rpl_reset.inc |
| 65 |
--let $rpl_only_running_threads= 0 |
| 66 |
|
| 67 |
--echo # |
| 68 |
--echo # Main test of semi-sync replication starts here |
| 69 |
--echo # |
| 70 |
|
| 71 |
source include/rpl_connection_master.inc; |
| 72 |
let $value = query_get_value(show variables like 'rpl_semi_sync_source_enabled', Value, 1); |
| 73 |
if ($value == No such row) |
| 74 |
{ |
| 75 |
disable_query_log; |
| 76 |
eval INSTALL PLUGIN rpl_semi_sync_source SONAME '$SEMISYNC_SOURCE_PLUGIN'; |
| 77 |
set global rpl_semi_sync_source_timeout= 60000 /* 60s */; |
| 78 |
set global rpl_semi_sync_source_wait_point= AFTER_COMMIT; |
| 79 |
enable_query_log; |
| 80 |
} |
| 81 |
|
| 82 |
echo [ default state of semi-sync on master should be OFF ]; |
| 83 |
show variables like 'rpl_semi_sync_source_enabled'; |
| 84 |
|
| 85 |
echo [ enable semi-sync on master ]; |
| 86 |
set global rpl_semi_sync_source_enabled = 1; |
| 87 |
show variables like 'rpl_semi_sync_source_enabled'; |
| 88 |
|
| 89 |
echo [ status of semi-sync on master should be ON even without any semi-sync slaves ]; |
| 90 |
show status like 'Rpl_semi_sync_source_clients'; |
| 91 |
show status like 'Rpl_semi_sync_source_status'; |
| 92 |
show status like 'Rpl_semi_sync_source_yes_tx'; |
| 93 |
|
| 94 |
--echo # |
| 95 |
--echo # BUG#45672 Semisync repl: ActiveTranx:insert_tranx_node: transaction node allocation failed |
| 96 |
--echo # BUG#45673 Semisync reports correct operation even if no slave is connected |
| 97 |
--echo # |
| 98 |
|
| 99 |
# BUG#45672 When semi-sync is enabled on master, it would allocate |
| 100 |
# transaction node even without semi-sync slave connected, and would |
| 101 |
# finally result in transaction node allocation error. |
| 102 |
# |
| 103 |
# Semi-sync master will pre-allocate 'max_connections' transaction |
| 104 |
# nodes, so here we do more than that much transactions to check if it |
| 105 |
# will fail or not. |
| 106 |
# select @@global.max_connections + 1; |
| 107 |
let $i= `select @@global.max_connections + 1`; |
| 108 |
disable_query_log; |
| 109 |
eval create table t1 (a int) engine=$engine_type; |
| 110 |
while ($i) |
| 111 |
{ |
| 112 |
eval insert into t1 values ($i); |
| 113 |
dec $i; |
| 114 |
} |
| 115 |
drop table t1; |
| 116 |
enable_query_log; |
| 117 |
|
| 118 |
# BUG#45673 |
| 119 |
echo [ status of semi-sync on master should be OFF ]; |
| 120 |
show status like 'Rpl_semi_sync_source_clients'; |
| 121 |
show status like 'Rpl_semi_sync_source_status'; |
| 122 |
show status like 'Rpl_semi_sync_source_yes_tx'; |
| 123 |
|
| 124 |
if ($rpl_test_optimize_for_static_plugin_config == 1) |
| 125 |
{ |
| 126 |
SET GLOBAL replication_optimize_for_static_plugin_config = 1; |
| 127 |
} |
| 128 |
|
| 129 |
# reset master and slave so the following test starts in a clean environment |
| 130 |
--let $rpl_only_running_threads= 1 |
| 131 |
--let $rpl_no_start_slave= 1 |
| 132 |
--source include/rpl_reset.inc |
| 133 |
--let $rpl_only_running_threads= 0 |
| 134 |
|
| 135 |
--echo # |
| 136 |
--echo # INSTALL PLUGIN semi-sync on slave |
| 137 |
--echo # |
| 138 |
|
| 139 |
source include/rpl_connection_slave.inc; |
| 140 |
let $value= query_get_value(show variables like 'rpl_semi_sync_replica_enabled', Value, 1); |
| 141 |
if ($value == No such row) |
| 142 |
{ |
| 143 |
disable_query_log; |
| 144 |
eval INSTALL PLUGIN rpl_semi_sync_replica SONAME '$SEMISYNC_REPLICA_PLUGIN'; |
| 145 |
enable_query_log; |
| 146 |
} |
| 147 |
|
| 148 |
echo [ default state of semi-sync on slave should be OFF ]; |
| 149 |
show variables like 'rpl_semi_sync_replica_enabled'; |
| 150 |
|
| 151 |
echo [ enable semi-sync on slave ]; |
| 152 |
set global rpl_semi_sync_replica_enabled = 1; |
| 153 |
show variables like 'rpl_semi_sync_replica_enabled'; |
| 154 |
source include/start_slave.inc; |
| 155 |
|
| 156 |
source include/rpl_connection_master.inc; |
| 157 |
# NOTE: Rpl_semi_sync_master_client will only be updated when |
| 158 |
# semi-sync slave has started binlog dump request |
| 159 |
let $status_var= Rpl_semi_sync_source_clients; |
| 160 |
let $status_var_value= 1; |
| 161 |
source include/wait_for_status_var.inc; |
| 162 |
|
| 163 |
echo [ initial master state after the semi-sync slave connected ]; |
| 164 |
show status like 'Rpl_semi_sync_source_clients'; |
| 165 |
show status like 'Rpl_semi_sync_source_status'; |
| 166 |
show status like 'Rpl_semi_sync_source_no_tx'; |
| 167 |
show status like 'Rpl_semi_sync_source_yes_tx'; |
| 168 |
|
| 169 |
--let $yes_tx_before= query_get_value(SHOW STATUS LIKE 'Rpl_semi_sync_source_yes_tx', Value, 1) |
| 170 |
|
| 171 |
replace_result $engine_type ENGINE_TYPE; |
| 172 |
eval create table t1(a int) engine = $engine_type; |
| 173 |
|
| 174 |
# wait for the ack to arrive |
| 175 |
--let $yes_tx_after= `SELECT $yes_tx_before + 1` |
| 176 |
--let $status_var= Rpl_semi_sync_source_yes_tx |
| 177 |
--let $status_var_value= $yes_tx_after |
| 178 |
--source include/wait_for_status_var.inc |
| 179 |
|
| 180 |
echo [ master state after CREATE TABLE statement ]; |
| 181 |
show status like 'Rpl_semi_sync_source_status'; |
| 182 |
show status like 'Rpl_semi_sync_source_no_tx'; |
| 183 |
show status like 'Rpl_semi_sync_source_yes_tx'; |
| 184 |
|
| 185 |
# After fix of BUG#45848, semi-sync slave should not create any extra |
| 186 |
# connections on master. |
| 187 |
let $_connections_semisync_replica= query_get_value(SHOW STATUS LIKE 'Threads_connected', Value, 1); |
| 188 |
replace_result $_connections_semisync_replica CONNECTIONS_SEMISYNC_SLAVE; |
| 189 |
replace_result $_connections_normal_slave CONNECTIONS_NORMAL_SLAVE; |
| 190 |
eval select $_connections_semisync_replica - $_connections_normal_slave as 'Should be 0'; |
| 191 |
|
| 192 |
--let $yes_tx_before= query_get_value(SHOW STATUS LIKE 'Rpl_semi_sync_source_yes_tx', Value, 1) |
| 193 |
|
| 194 |
let $i=10; |
| 195 |
--let $acks_to_wait= 0 |
| 196 |
echo [ insert records to table ]; |
| 197 |
disable_query_log; |
| 198 |
while ($i) |
| 199 |
{ |
| 200 |
eval insert into t1 values ($i); |
| 201 |
dec $i; |
| 202 |
inc $acks_to_wait; |
| 203 |
} |
| 204 |
enable_query_log; |
| 205 |
|
| 206 |
# Wait for acks from slave to avoid test failures on slow platforms. |
| 207 |
--let $yes_tx_after= `SELECT $yes_tx_before + $acks_to_wait` |
| 208 |
let $status_var= Rpl_semi_sync_source_yes_tx; |
| 209 |
let $status_var_value= $yes_tx_after; |
| 210 |
let $status_timeout= 2400; |
| 211 |
let $status_fail_query= SHOW STATUS LIKE 'Rpl_semi_sync%'; |
| 212 |
source include/wait_for_status_var.inc; |
| 213 |
|
| 214 |
echo [ master status after inserts ]; |
| 215 |
show status like 'Rpl_semi_sync_source_status'; |
| 216 |
show status like 'Rpl_semi_sync_source_no_tx'; |
| 217 |
show status like 'Rpl_semi_sync_source_yes_tx'; |
| 218 |
|
| 219 |
--source include/sync_slave_sql_with_master.inc |
| 220 |
echo [ on slave ]; |
| 221 |
|
| 222 |
echo [ slave status after replicated inserts ]; |
| 223 |
show status like 'Rpl_semi_sync_replica_status'; |
| 224 |
|
| 225 |
select count(distinct a) from t1; |
| 226 |
select min(a) from t1; |
| 227 |
select max(a) from t1; |
| 228 |
|
| 229 |
--echo |
| 230 |
--echo # BUG#50157 |
| 231 |
--echo # semi-sync replication crashes when replicating a transaction which |
| 232 |
--echo # include 'CREATE TEMPORARY TABLE `MyISAM_t` SELECT * FROM `Innodb_t` ; |
| 233 |
|
| 234 |
source include/rpl_connection_master.inc; |
| 235 |
SET SESSION AUTOCOMMIT= 0; |
| 236 |
CREATE TABLE t2(c1 INT) ENGINE=innodb; |
| 237 |
--source include/sync_slave_sql_with_master.inc |
| 238 |
|
| 239 |
connection master; |
| 240 |
BEGIN; |
| 241 |
--echo |
| 242 |
--echo # Even though it is in a transaction, this statement is binlogged into binlog |
| 243 |
--echo # file immediately. |
| 244 |
--disable_warnings |
| 245 |
CREATE TEMPORARY TABLE t3 SELECT c1 FROM t2 where 1=1; |
| 246 |
--enable_warnings |
| 247 |
--echo |
| 248 |
--echo # These statements will not be binlogged until the transaction is committed |
| 249 |
INSERT INTO t2 VALUES(11); |
| 250 |
INSERT INTO t2 VALUES(22); |
| 251 |
COMMIT; |
| 252 |
|
| 253 |
DROP TABLE t2, t3; |
| 254 |
SET SESSION AUTOCOMMIT= 1; |
| 255 |
|
| 256 |
# The temporary table above will be binlogged in statement mode only, resulting |
| 257 |
# in different Rpl_semi_sync_source_yes_tx values in statement vs row/mixed. Reset it. |
| 258 |
FLUSH STATUS; |
| 259 |
|
| 260 |
--source include/sync_slave_sql_with_master.inc |
| 261 |
|
| 262 |
|
| 263 |
--echo # |
| 264 |
--echo # Test semi-sync master will switch OFF after one transaction |
| 265 |
--echo # timeout waiting for replica reply. |
| 266 |
--echo # |
| 267 |
connection slave; |
| 268 |
source include/stop_slave.inc; |
| 269 |
|
| 270 |
source include/rpl_connection_master.inc; |
| 271 |
# Kill the dump thread(s) on master for previous slave connection |
| 272 |
source include/stop_dump_threads.inc; |
| 273 |
# Rpl_semi_sync_source_clients should be 0, once the dump thread(s) have exited. |
| 274 |
let $status_var= Rpl_semi_sync_source_clients; |
| 275 |
let $status_var_value= 0; |
| 276 |
source include/wait_for_status_var.inc; |
| 277 |
|
| 278 |
# The first semi-sync check should be on because after slave stop, |
| 279 |
# there are no transactions on the master. |
| 280 |
echo [ master status should be ON ]; |
| 281 |
show status like 'Rpl_semi_sync_source_status'; |
| 282 |
show status like 'Rpl_semi_sync_source_no_tx'; |
| 283 |
show status like 'Rpl_semi_sync_source_yes_tx'; |
| 284 |
show status like 'Rpl_semi_sync_source_clients'; |
| 285 |
|
| 286 |
echo [ semi-sync replication of these transactions will fail ]; |
| 287 |
insert into t1 values (500); |
| 288 |
|
| 289 |
# Wait for the semi-sync replication of this transaction to timeout |
| 290 |
let $status_var= Rpl_semi_sync_source_status; |
| 291 |
let $status_var_value= OFF; |
| 292 |
source include/wait_for_status_var.inc; |
| 293 |
|
| 294 |
# The second semi-sync check should be off because one transaction |
| 295 |
# times out during waiting. |
| 296 |
echo [ master status should be OFF ]; |
| 297 |
show status like 'Rpl_semi_sync_source_status'; |
| 298 |
show status like 'Rpl_semi_sync_source_no_tx'; |
| 299 |
show status like 'Rpl_semi_sync_source_yes_tx'; |
| 300 |
|
| 301 |
# Semi-sync status on master is now OFF, so all these transactions |
| 302 |
# will be replicated asynchronously. |
| 303 |
let $i=10; |
| 304 |
disable_query_log; |
| 305 |
while ($i) |
| 306 |
{ |
| 307 |
eval delete from t1 where a=$i; |
| 308 |
dec $i; |
| 309 |
} |
| 310 |
enable_query_log; |
| 311 |
|
| 312 |
insert into t1 values (100); |
| 313 |
|
| 314 |
echo [ master status should be OFF ]; |
| 315 |
show status like 'Rpl_semi_sync_source_status'; |
| 316 |
show status like 'Rpl_semi_sync_source_no_tx'; |
| 317 |
show status like 'Rpl_semi_sync_source_yes_tx'; |
| 318 |
|
| 319 |
--echo # |
| 320 |
--echo # Test semi-sync status on master will be ON again when slave catches up |
| 321 |
--echo # |
| 322 |
|
| 323 |
# Save the master position for later use. |
| 324 |
save_master_pos; |
| 325 |
|
| 326 |
source include/rpl_connection_slave.inc; |
| 327 |
echo [ slave status should be OFF ]; |
| 328 |
show status like 'Rpl_semi_sync_replica_status'; |
| 329 |
source include/start_slave.inc; |
| 330 |
sync_with_master; |
| 331 |
|
| 332 |
echo [ slave status should be ON ]; |
| 333 |
show status like 'Rpl_semi_sync_replica_status'; |
| 334 |
|
| 335 |
select count(distinct a) from t1; |
| 336 |
select min(a) from t1; |
| 337 |
select max(a) from t1; |
| 338 |
|
| 339 |
source include/rpl_connection_master.inc; |
| 340 |
# Wait until master semi-sync status is on again after slave catches up |
| 341 |
# to avoid test failures on slow platforms. |
| 342 |
let $status_var= Rpl_semi_sync_source_status; |
| 343 |
let $status_var_value= ON; |
| 344 |
source include/wait_for_status_var.inc; |
| 345 |
|
| 346 |
echo [ master status should be ON again after slave catches up ]; |
| 347 |
show status like 'Rpl_semi_sync_source_status'; |
| 348 |
show status like 'Rpl_semi_sync_source_no_tx'; |
| 349 |
show status like 'Rpl_semi_sync_source_yes_tx'; |
| 350 |
show status like 'Rpl_semi_sync_source_clients'; |
| 351 |
|
| 352 |
--echo # |
| 353 |
--echo # Test disable/enable master semi-sync on the fly. |
| 354 |
--echo # |
| 355 |
|
| 356 |
drop table t1; |
| 357 |
--source include/sync_slave_sql_with_master.inc |
| 358 |
echo [ on slave ]; |
| 359 |
|
| 360 |
source include/stop_slave.inc; |
| 361 |
|
| 362 |
--echo # |
| 363 |
--echo # Flush status |
| 364 |
--echo # |
| 365 |
connection master; |
| 366 |
echo [ Semi-sync master status variables before FLUSH STATUS ]; |
| 367 |
SHOW STATUS LIKE 'Rpl_semi_sync_source_no_tx'; |
| 368 |
SHOW STATUS LIKE 'Rpl_semi_sync_source_yes_tx'; |
| 369 |
# Do not write the FLUSH STATUS to binlog, to make sure we'll get a |
| 370 |
# clean status after this. |
| 371 |
FLUSH NO_WRITE_TO_BINLOG STATUS; |
| 372 |
echo [ Semi-sync master status variables after FLUSH STATUS ]; |
| 373 |
SHOW STATUS LIKE 'Rpl_semi_sync_source_no_tx'; |
| 374 |
SHOW STATUS LIKE 'Rpl_semi_sync_source_yes_tx'; |
| 375 |
|
| 376 |
source include/rpl_connection_master.inc; |
| 377 |
source include/show_master_logs.inc; |
| 378 |
show variables like 'rpl_semi_sync_source_enabled'; |
| 379 |
|
| 380 |
echo [ disable semi-sync on the fly ]; |
| 381 |
set global rpl_semi_sync_source_enabled=0; |
| 382 |
show variables like 'rpl_semi_sync_source_enabled'; |
| 383 |
show status like 'Rpl_semi_sync_source_status'; |
| 384 |
|
| 385 |
echo [ enable semi-sync on the fly ]; |
| 386 |
set global rpl_semi_sync_source_enabled=1; |
| 387 |
show variables like 'rpl_semi_sync_source_enabled'; |
| 388 |
show status like 'Rpl_semi_sync_source_status'; |
| 389 |
|
| 390 |
--echo # |
| 391 |
--echo # Test RESET MASTER/SLAVE |
| 392 |
--echo # |
| 393 |
|
| 394 |
source include/rpl_connection_slave.inc; |
| 395 |
source include/start_slave.inc; |
| 396 |
|
| 397 |
source include/rpl_connection_master.inc; |
| 398 |
replace_result $engine_type ENGINE_TYPE; |
| 399 |
eval create table t1 (a int) engine = $engine_type; |
| 400 |
drop table t1; |
| 401 |
|
| 402 |
--source include/sync_slave_sql_with_master.inc |
| 403 |
--replace_column 2 # |
| 404 |
show status like 'Rpl_relay%'; |
| 405 |
|
| 406 |
echo [ test reset master ]; |
| 407 |
source include/rpl_connection_master.inc; |
| 408 |
|
| 409 |
reset master; |
| 410 |
|
| 411 |
show status like 'Rpl_semi_sync_source_status'; |
| 412 |
show status like 'Rpl_semi_sync_source_no_tx'; |
| 413 |
show status like 'Rpl_semi_sync_source_yes_tx'; |
| 414 |
|
| 415 |
source include/rpl_connection_slave.inc; |
| 416 |
source include/stop_slave.inc; |
| 417 |
reset slave; |
| 418 |
reset master; |
| 419 |
|
| 420 |
source include/rpl_connection_master.inc; |
| 421 |
# Kill the dump thread(s) on master for previous slave connection |
| 422 |
source include/stop_dump_threads.inc; |
| 423 |
# Rpl_semi_sync_source_clients should be 0, once the dump thread(s) have exited. |
| 424 |
let $status_var= Rpl_semi_sync_source_clients; |
| 425 |
let $status_var_value= 0; |
| 426 |
source include/wait_for_status_var.inc; |
| 427 |
|
| 428 |
connection slave; |
| 429 |
source include/start_slave.inc; |
| 430 |
|
| 431 |
source include/rpl_connection_master.inc; |
| 432 |
# Wait for dump thread to start, Rpl_semi_sync_source_clients should be |
| 433 |
# 1 after dump thread started. |
| 434 |
let $status_var= Rpl_semi_sync_source_clients; |
| 435 |
let $status_var_value= 1; |
| 436 |
source include/wait_for_status_var.inc; |
| 437 |
|
| 438 |
replace_result $engine_type ENGINE_TYPE; |
| 439 |
eval create table t1 (a int) engine = $engine_type; |
| 440 |
insert into t1 values (1); |
| 441 |
insert into t1 values (2), (3); |
| 442 |
|
| 443 |
--source include/sync_slave_sql_with_master.inc |
| 444 |
echo [ on slave ]; |
| 445 |
select * from t1; |
| 446 |
|
| 447 |
source include/rpl_connection_master.inc; |
| 448 |
# Wait until master semi-sync status is on again after slave catches up |
| 449 |
# to avoid test failures on slow platforms. |
| 450 |
let $status_var= Rpl_semi_sync_source_status; |
| 451 |
let $status_var_value= ON; |
| 452 |
source include/wait_for_status_var.inc; |
| 453 |
|
| 454 |
echo [ master semi-sync status should be ON ]; |
| 455 |
show status like 'Rpl_semi_sync_source_status'; |
| 456 |
show status like 'Rpl_semi_sync_source_no_tx'; |
| 457 |
show status like 'Rpl_semi_sync_source_yes_tx'; |
| 458 |
|
| 459 |
|
| 460 |
--echo # |
| 461 |
--echo # Start semi-sync replication without SUPER privilege |
| 462 |
--echo # |
| 463 |
--source include/rpl_reset.inc |
| 464 |
|
| 465 |
source include/rpl_connection_master.inc; |
| 466 |
# Kill the dump thread on master for previous slave connection |
| 467 |
source include/stop_dump_threads.inc; |
| 468 |
# Rpl_semi_sync_source_clients should be 0, once dump thread(s) have exited |
| 469 |
let $status_var= Rpl_semi_sync_source_clients; |
| 470 |
let $status_var_value= 0; |
| 471 |
source include/wait_for_status_var.inc; |
| 472 |
|
| 473 |
# Do not binlog the following statement because it will generate |
| 474 |
# different events for ROW and STATEMENT format |
| 475 |
set sql_log_bin=0; |
| 476 |
create user [email protected] identified by 'rpl'; |
| 477 |
grant replication slave on *.* to [email protected]; |
| 478 |
flush privileges; |
| 479 |
set sql_log_bin=1; |
| 480 |
# Prove of bug#77732 fixes: |
| 481 |
# Created user's privileges - REPLICATION and SLAVE - |
| 482 |
# alone must suffice to successful connecting even with show handler |
| 483 |
# not compatible to 5.6. |
| 484 |
|
| 485 |
source include/rpl_connection_slave.inc; |
| 486 |
create user [email protected] identified by 'rpl'; |
| 487 |
grant replication slave on *.* to [email protected]; |
| 488 |
flush privileges; |
| 489 |
--replace_column 2 #### |
| 490 |
CHANGE REPLICATION SOURCE to SOURCE_USER='rpl',SOURCE_PASSWORD='rpl', GET_SOURCE_PUBLIC_KEY=1; |
| 491 |
source include/start_slave.inc; |
| 492 |
show status like 'Rpl_semi_sync_replica_status'; |
| 493 |
source include/rpl_connection_master.inc; |
| 494 |
|
| 495 |
# bug#77732 related: reconnecting to the master while the show handler |
| 496 |
# is compatible with 5.6 |
| 497 |
--source include/rpl_connection_slave.inc |
| 498 |
source include/stop_slave.inc; |
| 499 |
|
| 500 |
--source include/rpl_connection_master.inc |
| 501 |
# Added for Bug#19372027: rpl_semi_sync fails sporadically on trunk |
| 502 |
# To ensure that master knows that the slave is stopped |
| 503 |
Insert into t1 values (4); |
| 504 |
# wait for semi sync binlog dump thread to stop |
| 505 |
let $status_var= Rpl_semi_sync_source_clients; |
| 506 |
let $status_var_value= 0; |
| 507 |
source include/wait_for_status_var.inc; |
| 508 |
show status like 'Rpl_semi_sync_source_status'; |
| 509 |
show status like 'Rpl_semi_sync_source_clients'; |
| 510 |
|
| 511 |
source include/rpl_connection_slave.inc; |
| 512 |
source include/start_slave.inc; |
| 513 |
show status like 'Rpl_semi_sync_replica_status'; |
| 514 |
|
| 515 |
--source include/rpl_connection_master.inc |
| 516 |
# bug#77732 cleanup |
| 517 |
# Added for Bug#19372027:rpl_semi_sync fails sporadically on trunk |
| 518 |
let $status_var= Rpl_semi_sync_source_status; |
| 519 |
let $status_var_value= ON; |
| 520 |
source include/wait_for_status_var.inc; |
| 521 |
show status like 'Rpl_semi_sync_source_status'; |
| 522 |
|
| 523 |
# Wait for the semi-sync binlog dump thread to start |
| 524 |
let $status_var= Rpl_semi_sync_source_clients; |
| 525 |
let $status_var_value= 1; |
| 526 |
source include/wait_for_status_var.inc; |
| 527 |
echo [ master semi-sync should be ON ]; |
| 528 |
show status like 'Rpl_semi_sync_source_clients'; |
| 529 |
show status like 'Rpl_semi_sync_source_no_tx'; |
| 530 |
show status like 'Rpl_semi_sync_source_yes_tx'; |
| 531 |
insert into t1 values (5); |
| 532 |
insert into t1 values (6); |
| 533 |
|
| 534 |
# Wait for acks from slave to avoid test failures on slow platforms. |
| 535 |
let $status_var= Rpl_semi_sync_source_yes_tx; |
| 536 |
let $status_var_value= 2; |
| 537 |
source include/wait_for_status_var.inc; |
| 538 |
|
| 539 |
echo [ master semi-sync should be ON ]; |
| 540 |
show status like 'Rpl_semi_sync_source_clients'; |
| 541 |
show status like 'Rpl_semi_sync_source_status'; |
| 542 |
show status like 'Rpl_semi_sync_source_no_tx'; |
| 543 |
show status like 'Rpl_semi_sync_source_yes_tx'; |
| 544 |
|
| 545 |
# Bug#31327337: SUBSYSTEM NAME FOR SEMISYNC ERRORS IS [SERVER] - pt2 |
| 546 |
select subsystem, error_code |
| 547 |
from performance_schema.error_log |
| 548 |
where error_code="MY-011170" limit 1; |
| 549 |
|
| 550 |
--echo # |
| 551 |
--echo # Test semi-sync slave connect to non-semi-sync master |
| 552 |
--echo # |
| 553 |
|
| 554 |
# Disable semi-sync on master |
| 555 |
--source include/sync_slave_sql_with_master.inc |
| 556 |
echo [ on slave ]; |
| 557 |
source include/stop_slave.inc; |
| 558 |
SHOW STATUS LIKE 'Rpl_semi_sync_replica_status'; |
| 559 |
|
| 560 |
source include/rpl_connection_master.inc; |
| 561 |
# Kill the dump thread(s) on master for previous slave connection |
| 562 |
source include/stop_dump_threads.inc; |
| 563 |
# Rpl_semi_sync_source_clients should be 0, once dump thread(s) have exited |
| 564 |
let $status_var= Rpl_semi_sync_source_clients; |
| 565 |
let $status_var_value= 0; |
| 566 |
source include/wait_for_status_var.inc; |
| 567 |
|
| 568 |
echo [ Semi-sync status on master should be ON ]; |
| 569 |
show status like 'Rpl_semi_sync_source_clients'; |
| 570 |
show status like 'Rpl_semi_sync_source_status'; |
| 571 |
set global rpl_semi_sync_source_enabled= 0; |
| 572 |
|
| 573 |
source include/rpl_connection_slave.inc; |
| 574 |
SHOW VARIABLES LIKE 'rpl_semi_sync_replica_enabled'; |
| 575 |
source include/start_slave.inc; |
| 576 |
|
| 577 |
source include/rpl_connection_master.inc; |
| 578 |
insert into t1 values (8); |
| 579 |
let $status_var= Rpl_semi_sync_source_clients; |
| 580 |
let $status_var_value= 1; |
| 581 |
source include/wait_for_status_var.inc; |
| 582 |
echo [ master semi-sync clients should be 1, status should be OFF ]; |
| 583 |
show status like 'Rpl_semi_sync_source_clients'; |
| 584 |
show status like 'Rpl_semi_sync_source_status'; |
| 585 |
--source include/sync_slave_sql_with_master.inc |
| 586 |
echo [ on slave ]; |
| 587 |
show status like 'Rpl_semi_sync_replica_status'; |
| 588 |
|
| 589 |
# Uninstall semi-sync plugin on master |
| 590 |
connection slave; |
| 591 |
source include/stop_slave.inc; |
| 592 |
connection master; |
| 593 |
echo [ on master ]; |
| 594 |
--source include/stop_dump_threads.inc |
| 595 |
if ($rpl_test_optimize_for_static_plugin_config == 1) |
| 596 |
{ |
| 597 |
SET GLOBAL replication_optimize_for_static_plugin_config = 0; |
| 598 |
} |
| 599 |
UNINSTALL PLUGIN rpl_semi_sync_source; |
| 600 |
enable_query_log; |
| 601 |
SHOW VARIABLES LIKE 'rpl_semi_sync_source_enabled'; |
| 602 |
|
| 603 |
source include/rpl_connection_slave.inc; |
| 604 |
SHOW VARIABLES LIKE 'rpl_semi_sync_replica_enabled'; |
| 605 |
source include/start_slave.inc; |
| 606 |
|
| 607 |
source include/rpl_connection_master.inc; |
| 608 |
insert into t1 values (10); |
| 609 |
--source include/sync_slave_sql_with_master.inc |
| 610 |
echo [ on slave ]; |
| 611 |
SHOW STATUS LIKE 'Rpl_semi_sync_replica_status'; |
| 612 |
|
| 613 |
--echo # |
| 614 |
--echo # Test non-semi-sync slave connect to semi-sync master |
| 615 |
--echo # |
| 616 |
|
| 617 |
connection master; |
| 618 |
replace_result $SEMISYNC_SOURCE_PLUGIN SEMISYNC_SOURCE_PLUGIN; |
| 619 |
eval INSTALL PLUGIN rpl_semi_sync_source SONAME '$SEMISYNC_SOURCE_PLUGIN'; |
| 620 |
if ($rpl_test_optimize_for_static_plugin_config == 1) |
| 621 |
{ |
| 622 |
SET GLOBAL replication_optimize_for_static_plugin_config = 1; |
| 623 |
} |
| 624 |
set global rpl_semi_sync_source_timeout= 60000; /* 60s */ |
| 625 |
set global rpl_semi_sync_source_enabled= 1; |
| 626 |
|
| 627 |
source include/rpl_connection_slave.inc; |
| 628 |
source include/stop_slave.inc; |
| 629 |
SHOW STATUS LIKE 'Rpl_semi_sync_replica_status'; |
| 630 |
|
| 631 |
echo [ uninstall semi-sync slave plugin ]; |
| 632 |
UNINSTALL PLUGIN rpl_semi_sync_replica; |
| 633 |
SHOW VARIABLES LIKE 'rpl_semi_sync_replica_enabled'; |
| 634 |
source include/start_slave.inc; |
| 635 |
SHOW STATUS LIKE 'Rpl_semi_sync_replica_status'; |
| 636 |
source include/stop_slave.inc; |
| 637 |
|
| 638 |
echo [ reinstall semi-sync slave plugin and disable semi-sync ]; |
| 639 |
replace_result $SEMISYNC_REPLICA_PLUGIN SEMISYNC_REPLICA_PLUGIN; |
| 640 |
eval INSTALL PLUGIN rpl_semi_sync_replica SONAME '$SEMISYNC_REPLICA_PLUGIN'; |
| 641 |
set global rpl_semi_sync_replica_enabled= 0; |
| 642 |
SHOW VARIABLES LIKE 'rpl_semi_sync_replica_enabled'; |
| 643 |
SHOW STATUS LIKE 'Rpl_semi_sync_replica_status'; |
| 644 |
source include/start_slave.inc; |
| 645 |
SHOW STATUS LIKE 'Rpl_semi_sync_replica_status'; |
| 646 |
|
| 647 |
--echo # |
| 648 |
--echo # Clean up |
| 649 |
--echo # |
| 650 |
if ($rpl_test_optimize_for_static_plugin_config == 1) |
| 651 |
{ |
| 652 |
connection master; |
| 653 |
SET GLOBAL replication_optimize_for_static_plugin_config = 0; |
| 654 |
} |
| 655 |
--source include/uninstall_semisync.inc |
| 656 |
|
| 657 |
connection slave; |
| 658 |
--source include/stop_slave.inc |
| 659 |
--replace_column 2 #### |
| 660 |
CHANGE REPLICATION SOURCE to SOURCE_USER='root',SOURCE_PASSWORD='', GET_SOURCE_PUBLIC_KEY=0; |
| 661 |
source include/start_slave.inc; |
| 662 |
|
| 663 |
connection master; |
| 664 |
drop table t1; |
| 665 |
--source include/sync_slave_sql_with_master.inc |
| 666 |
|
| 667 |
connection master; |
| 668 |
drop user [email protected]; |
| 669 |
flush privileges; |
| 670 |
--source include/rpl_end.inc |