Skip to content

Commit ce7d020

Browse files
committed
MDEV-38497 Remove all slave related configurations on RESET SLAVE ALL
Fix RESET SLAVE ALL to fully clear replica configuration of the default unnamed slave, including SSL options, so subsequent CHANGE MASTER starts from a clean state. Signed-off-by: Dearsh Oberoi <oberoidearsh@gmail.com>
1 parent 21a0714 commit ce7d020

3 files changed

Lines changed: 170 additions & 0 deletions

File tree

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#
2+
# MDEV-38497 RESET SLAVE ALL doesn't remove all slave related configurations
3+
#
4+
include/master-slave.inc
5+
[connection master]
6+
connection slave;
7+
STOP REPLICA;
8+
include/wait_for_slave_io_to_stop.inc
9+
include/wait_for_slave_sql_to_stop.inc
10+
CHANGE MASTER TO
11+
MASTER_HOST='localhost',
12+
MASTER_USER='replssl',
13+
MASTER_PASSWORD='password',
14+
MASTER_PORT=3001,
15+
MASTER_CONNECT_RETRY=7,
16+
MASTER_HEARTBEAT_PERIOD=9,
17+
MASTER_SSL=1,
18+
MASTER_SSL_CA='MYSQL_TEST_DIR/std_data/cacert.pem',
19+
MASTER_SSL_CAPATH='MYSQL_TEST_DIR/std_data',
20+
MASTER_SSL_CERT='MYSQL_TEST_DIR/std_data/client-cert.pem',
21+
MASTER_SSL_KEY='MYSQL_TEST_DIR/std_data/client-key.pem',
22+
MASTER_SSL_CRL='MYSQL_TEST_DIR/std_data/crl.pem',
23+
MASTER_SSL_CRLPATH='MYSQL_TEST_DIR/std_data',
24+
MASTER_SSL_CIPHER='AES256-SHA',
25+
MASTER_SSL_VERIFY_SERVER_CERT=1,
26+
MASTER_RETRY_COUNT=17,
27+
MASTER_USE_GTID=slave_pos,
28+
IGNORE_SERVER_IDS=(123),
29+
DO_DOMAIN_IDS=(19);
30+
RESET REPLICA ALL;
31+
CHANGE MASTER TO MASTER_HOST='localhost';
32+
SHOW REPLICA STATUS;
33+
Slave_IO_State
34+
Master_Host localhost
35+
Master_User
36+
Master_Port 3306
37+
Connect_Retry 0
38+
Master_Log_File
39+
Read_Master_Log_Pos 4
40+
Relay_Log_File slave-relay-bin.000001
41+
Relay_Log_Pos 4
42+
Relay_Master_Log_File
43+
Slave_IO_Running No
44+
Slave_SQL_Running No
45+
Replicate_Do_DB
46+
Replicate_Ignore_DB
47+
Replicate_Do_Table
48+
Replicate_Ignore_Table
49+
Replicate_Wild_Do_Table
50+
Replicate_Wild_Ignore_Table
51+
Last_Errno 0
52+
Last_Error
53+
Skip_Counter 0
54+
Exec_Master_Log_Pos 0
55+
Relay_Log_Space 257
56+
Until_Condition None
57+
Until_Log_File
58+
Until_Log_Pos 0
59+
Master_SSL_Allowed Yes
60+
Master_SSL_CA_File
61+
Master_SSL_CA_Path
62+
Master_SSL_Cert
63+
Master_SSL_Cipher
64+
Master_SSL_Key
65+
Seconds_Behind_Master NULL
66+
Master_SSL_Verify_Server_Cert No
67+
Last_IO_Errno 0
68+
Last_IO_Error
69+
Last_SQL_Errno 0
70+
Last_SQL_Error
71+
Replicate_Ignore_Server_Ids
72+
Master_Server_Id 1
73+
Master_SSL_Crl
74+
Master_SSL_Crlpath
75+
Using_Gtid Slave_Pos
76+
Gtid_IO_Pos
77+
Replicate_Do_Domain_Ids
78+
Replicate_Ignore_Domain_Ids
79+
Parallel_Mode optimistic
80+
SQL_Delay 0
81+
SQL_Remaining_Delay NULL
82+
Slave_SQL_Running_State
83+
Slave_DDL_Groups 0
84+
Slave_Non_Transactional_Groups 0
85+
Slave_Transactional_Groups 0
86+
Replicate_Rewrite_DB
87+
Connects_Tried 0
88+
Master_Retry_Count 0
89+
RESET REPLICA ALL;
90+
# End of reset_slave_all_leaks_master_info.test
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
--echo #
2+
--echo # MDEV-38497 RESET SLAVE ALL doesn't remove all slave related configurations
3+
--echo #
4+
5+
# Test replica should clear ALL master connection info
6+
7+
--source include/master-slave.inc
8+
9+
connection slave;
10+
11+
STOP REPLICA;
12+
--source include/wait_for_slave_io_to_stop.inc
13+
--source include/wait_for_slave_sql_to_stop.inc
14+
15+
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
16+
eval CHANGE MASTER TO
17+
MASTER_HOST='localhost',
18+
MASTER_USER='replssl',
19+
MASTER_PASSWORD='password',
20+
MASTER_PORT=3001,
21+
MASTER_CONNECT_RETRY=7,
22+
MASTER_HEARTBEAT_PERIOD=9,
23+
MASTER_SSL=1,
24+
MASTER_SSL_CA='$MYSQL_TEST_DIR/std_data/cacert.pem',
25+
MASTER_SSL_CAPATH='$MYSQL_TEST_DIR/std_data',
26+
MASTER_SSL_CERT='$MYSQL_TEST_DIR/std_data/client-cert.pem',
27+
MASTER_SSL_KEY='$MYSQL_TEST_DIR/std_data/client-key.pem',
28+
MASTER_SSL_CRL='$MYSQL_TEST_DIR/std_data/crl.pem',
29+
MASTER_SSL_CRLPATH='$MYSQL_TEST_DIR/std_data',
30+
MASTER_SSL_CIPHER='AES256-SHA',
31+
MASTER_SSL_VERIFY_SERVER_CERT=1,
32+
MASTER_RETRY_COUNT=17,
33+
MASTER_USE_GTID=slave_pos,
34+
IGNORE_SERVER_IDS=(123),
35+
DO_DOMAIN_IDS=(19);
36+
37+
#
38+
# Everything must be cleared / set to default values
39+
#
40+
RESET REPLICA ALL;
41+
42+
CHANGE MASTER TO MASTER_HOST='localhost';
43+
44+
--query_vertical SHOW REPLICA STATUS
45+
46+
# Cleanup
47+
RESET REPLICA ALL;
48+
49+
# --source include/rpl_end.inc
50+
51+
--echo # End of reset_slave_all_leaks_master_info.test

sql/rpl_mi.cc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828

2929
static void init_master_log_pos(Master_info* mi);
3030

31+
static void init_ssl_config(Master_info* mi);
32+
33+
static void init_connection_config(Master_info* mi);
34+
3135
Master_info::Master_info(LEX_CSTRING *connection_name_arg,
3236
bool is_slave_recovery):
3337
Master_info_file(ignore_server_ids, domain_id_filter.m_domain_ids[0],
@@ -177,9 +181,34 @@ void Master_info::clear_in_memory_info(bool all)
177181
host[0] = 0; user[0] = 0; password[0] = 0;
178182
domain_id_filter.clear_ids();
179183
reset_dynamic(&ignore_server_ids);
184+
init_ssl_config(this);
185+
init_connection_config(this);
180186
}
181187
}
182188

189+
190+
void init_ssl_config(Master_info* mi)
191+
{
192+
DBUG_ENTER("init_ssl_config");
193+
mi->master_ssl= 1;
194+
mi->master_ssl_verify_server_cert= 0;
195+
mi->master_ssl_ca= nullptr; mi->master_ssl_capath= nullptr; mi->master_ssl_cert= nullptr;
196+
mi->master_ssl_cipher= nullptr; mi->master_ssl_key= nullptr; mi->master_ssl_crl= nullptr;
197+
mi->master_ssl_crlpath= nullptr;
198+
DBUG_VOID_RETURN;
199+
}
200+
201+
202+
void init_connection_config(Master_info* mi)
203+
{
204+
DBUG_ENTER("init_connection_config");
205+
mi->connect_retry= 0;
206+
mi->retry_count= 0;
207+
mi->connects_tried= 0;
208+
DBUG_VOID_RETURN;
209+
}
210+
211+
183212
void init_master_log_pos(Master_info* mi)
184213
{
185214
DBUG_ENTER("init_master_log_pos");

0 commit comments

Comments
 (0)