Browse Source
MDEV-36663 Semi-sync Replica Can't Kill Dump Thread When Using SSL
MDEV-36663 Semi-sync Replica Can't Kill Dump Thread When Using SSL
When a replica stops an established semi-sync connection, it is supposed to kill the corresponding binlog dump thread on the primary server. However, when connections are configured to use SSL, this new connection created by the replica to kill the dump thread doesn't have any logic to configure SSL options, and thereby the connection can't be made, and the dump thread will never be killed. This patch adds logic to configure the semi-sync kill connection with SSL. The exising logic to set up the connection options for the regular connection was extracted into a function that the semi-sync kill connection invokes. Co-author: Brandon Nesterenko <brandon.nesterenko@mariadb.com>pull/4006/head
committed by
Brandon Nesterenko
7 changed files with 220 additions and 46 deletions
-
53mysql-test/suite/rpl/r/rpl_semi_sync_ssl_stop.result
-
100mysql-test/suite/rpl/t/rpl_semi_sync_ssl_stop.test
-
49sql/rpl_mi.cc
-
11sql/rpl_mi.h
-
9sql/semisync_slave.cc
-
2sql/semisync_slave.h
-
42sql/slave.cc
@ -0,0 +1,53 @@ |
|||
# Skip starting the slave because we manually start with SSL later |
|||
include/master-slave.inc |
|||
[connection master] |
|||
# |
|||
# Setup |
|||
connection master; |
|||
CREATE USER replssl@localhost; |
|||
GRANT REPLICATION SLAVE on *.* to replssl@localhost REQUIRE SSL; |
|||
set @orig_master_enabled= @@GLOBAL.rpl_semi_sync_master_enabled; |
|||
SET @@GLOBAL.rpl_semi_sync_master_enabled= 1; |
|||
connection slave; |
|||
CHANGE MASTER TO |
|||
master_user='replssl', |
|||
master_password='', |
|||
master_ssl=1, |
|||
master_ssl_ca='MYSQL_TEST_DIR/std_data/cacert.pem', |
|||
master_ssl_cert='MYSQL_TEST_DIR/std_data/client-cert.pem', |
|||
master_ssl_key='MYSQL_TEST_DIR/std_data/client-key.pem'; |
|||
set @orig_slave_enabled= @@GLOBAL.rpl_semi_sync_slave_enabled; |
|||
SET @@GLOBAL.rpl_semi_sync_slave_enabled= 1; |
|||
include/start_slave.inc |
|||
connection master; |
|||
# Verify Semi-Sync is active |
|||
SHOW STATUS LIKE 'Rpl_semi_sync_master_clients'; |
|||
Variable_name Value |
|||
Rpl_semi_sync_master_clients 1 |
|||
# Create some table so slave can be seen as up-to-date and working |
|||
connection master; |
|||
CREATE TABLE t1 (a INT); |
|||
connection slave; |
|||
# Disconnect the slave and wait until the master's dump thread is gone |
|||
connection slave; |
|||
STOP SLAVE; |
|||
connection master; |
|||
# MDEV-36663: Verifying dump thread connection is killed.. |
|||
# ..done |
|||
# Cleanup |
|||
connection master; |
|||
SET @@GLOBAL.rpl_semi_sync_master_enabled= @orig_master_enabled; |
|||
DROP USER replssl@localhost; |
|||
DROP TABLE t1; |
|||
connection slave; |
|||
SET @@GLOBAL.rpl_semi_sync_slave_enabled= @orig_slave_enabled; |
|||
CHANGE MASTER TO |
|||
master_user='root', |
|||
master_ssl=0, |
|||
master_ssl_ca='', |
|||
master_ssl_cert='', |
|||
master_ssl_key=''; |
|||
connection slave; |
|||
include/start_slave.inc |
|||
include/rpl_end.inc |
|||
# End of rpl_semi_sync_ssl_stop.inc |
|||
@ -0,0 +1,100 @@ |
|||
# |
|||
# This test verifies that semi-sync setups configured to use SSL can kill |
|||
# the replication connection when the IO thread is stopped (e.g. from |
|||
# STOP SLAVE). The way it should happen, is that the IO thread creates a new |
|||
# connection to the primary which issues KILL on the connection id of the |
|||
# replication connection. MDEV-36663 reported an issue where this new |
|||
# kill-oriented connection could not connect to a primary when it requires |
|||
# connections to use SSL. |
|||
# |
|||
# This test sets up a semi-sync SSL master-slave topology, and stops the |
|||
# slave IO thread. It then validates that the connection was killed by using |
|||
# the wait_condition.inc utility to wait for the binlog dump thread to die, |
|||
# and also validates that the status variable Rpl_semi_sync_master_clients |
|||
# reports as 0. |
|||
# |
|||
# References: |
|||
# MDEV-36663: Semi-sync Replica Can't Kill Dump Thread When Using SSL |
|||
# |
|||
--source include/have_binlog_format_mixed.inc # format-agnostic |
|||
--source include/have_ssl_communication.inc |
|||
|
|||
--echo # Skip starting the slave because we manually start with SSL later |
|||
--let $rpl_skip_start_slave= 1 |
|||
--source include/master-slave.inc |
|||
|
|||
--echo # |
|||
--echo # Setup |
|||
--connection master |
|||
CREATE USER replssl@localhost; |
|||
GRANT REPLICATION SLAVE on *.* to replssl@localhost REQUIRE SSL; |
|||
|
|||
set @orig_master_enabled= @@GLOBAL.rpl_semi_sync_master_enabled; |
|||
SET @@GLOBAL.rpl_semi_sync_master_enabled= 1; |
|||
|
|||
--connection slave |
|||
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR |
|||
eval CHANGE MASTER TO |
|||
master_user='replssl', |
|||
master_password='', |
|||
master_ssl=1, |
|||
master_ssl_ca='$MYSQL_TEST_DIR/std_data/cacert.pem', |
|||
master_ssl_cert='$MYSQL_TEST_DIR/std_data/client-cert.pem', |
|||
master_ssl_key='$MYSQL_TEST_DIR/std_data/client-key.pem'; |
|||
|
|||
set @orig_slave_enabled= @@GLOBAL.rpl_semi_sync_slave_enabled; |
|||
SET @@GLOBAL.rpl_semi_sync_slave_enabled= 1; |
|||
|
|||
--source include/start_slave.inc |
|||
|
|||
--connection master |
|||
--echo # Verify Semi-Sync is active |
|||
--let $status_var= Rpl_semi_sync_master_status |
|||
--let $status_var_value= ON |
|||
--source include/wait_for_status_var.inc |
|||
SHOW STATUS LIKE 'Rpl_semi_sync_master_clients'; |
|||
|
|||
--echo # Create some table so slave can be seen as up-to-date and working |
|||
--connection master |
|||
CREATE TABLE t1 (a INT); |
|||
--sync_slave_with_master |
|||
|
|||
--echo # Disconnect the slave and wait until the master's dump thread is gone |
|||
--connection slave |
|||
STOP SLAVE; |
|||
--connection master |
|||
|
|||
--echo # MDEV-36663: Verifying dump thread connection is killed.. |
|||
# Prior to MDEV-36663 fixes, this would time out and |
|||
# Rpl_semi_sync_master_clients would remain 1. |
|||
--let $wait_condition= SELECT COUNT(*)=0 FROM information_schema.PROCESSLIST WHERE COMMAND = 'Binlog Dump' |
|||
--source include/wait_condition.inc |
|||
|
|||
--let $n_master_clients= query_get_value(SHOW STATUS LIKE 'Rpl_semi_sync_master_clients', Value, 1) |
|||
if ($n_master_clients) |
|||
{ |
|||
--echo # Rpl_semi_sync_master_clients: $n_master_clients |
|||
--die Semi-sync dump thread connection not killed |
|||
} |
|||
--echo # ..done |
|||
|
|||
--echo # Cleanup |
|||
--connection master |
|||
SET @@GLOBAL.rpl_semi_sync_master_enabled= @orig_master_enabled; |
|||
DROP USER replssl@localhost; |
|||
DROP TABLE t1; |
|||
|
|||
--connection slave |
|||
SET @@GLOBAL.rpl_semi_sync_slave_enabled= @orig_slave_enabled; |
|||
CHANGE MASTER TO |
|||
master_user='root', |
|||
master_ssl=0, |
|||
master_ssl_ca='', |
|||
master_ssl_cert='', |
|||
master_ssl_key=''; |
|||
|
|||
--connection slave |
|||
--source include/start_slave.inc |
|||
|
|||
--source include/rpl_end.inc |
|||
--echo # End of rpl_semi_sync_ssl_stop.inc |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue