| 1 |
# |
| 2 |
# This test verifies that semi-sync setups configured to use SSL can kill |
| 3 |
# the replication connection when the IO thread is stopped (e.g. from |
| 4 |
# STOP SLAVE). The way it should happen, is that the IO thread creates a new |
| 5 |
# connection to the primary which issues KILL on the connection id of the |
| 6 |
# replication connection. MDEV-36663 reported an issue where this new |
| 7 |
# kill-oriented connection could not connect to a primary when it requires |
| 8 |
# connections to use SSL. |
| 9 |
# |
| 10 |
# This test sets up a semi-sync SSL master-slave topology, and stops the |
| 11 |
# slave IO thread. It then validates that the connection was killed by using |
| 12 |
# the wait_condition.inc utility to wait for the binlog dump thread to die, |
| 13 |
# and also validates that the status variable Rpl_semi_sync_master_clients |
| 14 |
# reports as 0. |
| 15 |
# |
| 16 |
# References: |
| 17 |
# MDEV-36663: Semi-sync Replica Can't Kill Dump Thread When Using SSL |
| 18 |
# |
| 19 |
--source include/have_binlog_format_mixed.inc # format-agnostic |
| 20 |
--source include/have_ssl_communication.inc |
| 21 |
|
| 22 |
--echo # Skip starting the slave because we manually start with SSL later |
| 23 |
--let $rpl_skip_start_slave= 1 |
| 24 |
--source include/master-slave.inc |
| 25 |
|
| 26 |
--echo # |
| 27 |
--echo # Setup |
| 28 |
--connection master |
| 29 |
CREATE USER replssl@localhost; |
| 30 |
GRANT REPLICATION SLAVE on *.* to replssl@localhost REQUIRE SSL; |
| 31 |
|
| 32 |
set @orig_master_enabled= @@GLOBAL.rpl_semi_sync_master_enabled; |
| 33 |
SET @@GLOBAL.rpl_semi_sync_master_enabled= 1; |
| 34 |
|
| 35 |
--connection slave |
| 36 |
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR |
| 37 |
eval CHANGE MASTER TO |
| 38 |
master_user='replssl', |
| 39 |
master_password='', |
| 40 |
master_ssl=1, |
| 41 |
master_ssl_ca='$MYSQL_TEST_DIR/std_data/cacert.pem', |
| 42 |
master_ssl_cert='$MYSQL_TEST_DIR/std_data/client-cert.pem', |
| 43 |
master_ssl_key='$MYSQL_TEST_DIR/std_data/client-key.pem'; |
| 44 |
|
| 45 |
set @orig_slave_enabled= @@GLOBAL.rpl_semi_sync_slave_enabled; |
| 46 |
SET @@GLOBAL.rpl_semi_sync_slave_enabled= 1; |
| 47 |
|
| 48 |
--source include/start_slave.inc |
| 49 |
|
| 50 |
--connection master |
| 51 |
--echo # Verify Semi-Sync is active |
| 52 |
--let $status_var= Rpl_semi_sync_master_clients |
| 53 |
--let $status_var_value= 1 |
| 54 |
--source include/wait_for_status_var.inc |
| 55 |
SHOW STATUS LIKE 'Rpl_semi_sync_master_clients'; |
| 56 |
|
| 57 |
--echo # Create some table so slave can be seen as up-to-date and working |
| 58 |
--connection master |
| 59 |
CREATE TABLE t1 (a INT); |
| 60 |
--sync_slave_with_master |
| 61 |
|
| 62 |
--echo # Disconnect the slave and wait until the master's dump thread is gone |
| 63 |
--connection slave |
| 64 |
STOP SLAVE; |
| 65 |
--connection master |
| 66 |
|
| 67 |
--echo # MDEV-36663: Verifying dump thread connection is killed.. |
| 68 |
# Prior to MDEV-36663 fixes, this would time out and |
| 69 |
# Rpl_semi_sync_master_clients would remain 1. |
| 70 |
--let $wait_condition= SELECT COUNT(*)=0 FROM information_schema.PROCESSLIST WHERE USER = 'replssl' |
| 71 |
--source include/wait_condition.inc |
| 72 |
|
| 73 |
--let $n_master_clients= query_get_value(SHOW STATUS LIKE 'Rpl_semi_sync_master_clients', Value, 1) |
| 74 |
if ($n_master_clients) |
| 75 |
{ |
| 76 |
--echo # Rpl_semi_sync_master_clients: $n_master_clients |
| 77 |
--die Semi-sync dump thread connection not killed |
| 78 |
} |
| 79 |
--echo # ..done |
| 80 |
|
| 81 |
--echo # Cleanup |
| 82 |
--connection master |
| 83 |
SET @@GLOBAL.rpl_semi_sync_master_enabled= @orig_master_enabled; |
| 84 |
DROP USER replssl@localhost; |
| 85 |
DROP TABLE t1; |
| 86 |
|
| 87 |
--connection slave |
| 88 |
SET @@GLOBAL.rpl_semi_sync_slave_enabled= @orig_slave_enabled; |
| 89 |
CHANGE MASTER TO |
| 90 |
master_user='root', |
| 91 |
master_ssl=1, |
| 92 |
master_ssl_ca='', |
| 93 |
master_ssl_cert='', |
| 94 |
master_ssl_key=''; |
| 95 |
|
| 96 |
--connection slave |
| 97 |
--source include/start_slave.inc |
| 98 |
|
| 99 |
--source include/rpl_end.inc |
| 100 |
--echo # End of rpl_semi_sync_ssl_stop.inc |