Skip to content
/ server Public
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions mysql-test/suite/rpl/r/reset_slave_all_leaks_master_info.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#
# MDEV-38497 RESET SLAVE ALL doesn't remove all slave related configurations
#
include/master-slave.inc
[connection master]
connection slave;
STOP REPLICA;
include/wait_for_slave_io_to_stop.inc
include/wait_for_slave_sql_to_stop.inc
CHANGE MASTER TO
MASTER_HOST='localhost',
MASTER_USER='replssl',
MASTER_PASSWORD='password',
MASTER_PORT=3001,
MASTER_CONNECT_RETRY=7,
MASTER_HEARTBEAT_PERIOD=9,
MASTER_SSL=1,
MASTER_SSL_CA='MYSQL_TEST_DIR/std_data/cacert.pem',
MASTER_SSL_CAPATH='MYSQL_TEST_DIR/std_data',
MASTER_SSL_CERT='MYSQL_TEST_DIR/std_data/client-cert.pem',
MASTER_SSL_KEY='MYSQL_TEST_DIR/std_data/client-key.pem',
MASTER_SSL_CRL='MYSQL_TEST_DIR/std_data/crl.pem',
MASTER_SSL_CRLPATH='MYSQL_TEST_DIR/std_data',
MASTER_SSL_CIPHER='AES256-SHA',
MASTER_SSL_VERIFY_SERVER_CERT=1,
MASTER_RETRY_COUNT=17,
MASTER_USE_GTID=slave_pos,
IGNORE_SERVER_IDS=(123),
DO_DOMAIN_IDS=(19);
RESET REPLICA ALL;
CHANGE MASTER TO MASTER_HOST='localhost';
SHOW REPLICA STATUS;
Slave_IO_State
Master_Host localhost
Master_User
Master_Port 3306
Connect_Retry 0
Master_Log_File
Read_Master_Log_Pos 4
Relay_Log_File slave-relay-bin.000001
Relay_Log_Pos 4
Relay_Master_Log_File
Slave_IO_Running No
Slave_SQL_Running No
Replicate_Do_DB
Replicate_Ignore_DB
Replicate_Do_Table
Replicate_Ignore_Table
Replicate_Wild_Do_Table
Replicate_Wild_Ignore_Table
Last_Errno 0
Last_Error
Skip_Counter 0
Exec_Master_Log_Pos 0
Relay_Log_Space 257
Until_Condition None
Until_Log_File
Until_Log_Pos 0
Master_SSL_Allowed Yes
Master_SSL_CA_File
Master_SSL_CA_Path
Master_SSL_Cert
Master_SSL_Cipher
Master_SSL_Key
Seconds_Behind_Master NULL
Master_SSL_Verify_Server_Cert No
Last_IO_Errno 0
Last_IO_Error
Last_SQL_Errno 0
Last_SQL_Error
Replicate_Ignore_Server_Ids
Master_Server_Id 1
Master_SSL_Crl
Master_SSL_Crlpath
Using_Gtid Slave_Pos
Gtid_IO_Pos
Replicate_Do_Domain_Ids
Replicate_Ignore_Domain_Ids
Parallel_Mode optimistic
SQL_Delay 0
SQL_Remaining_Delay NULL
Slave_SQL_Running_State
Slave_DDL_Groups 0
Slave_Non_Transactional_Groups 0
Slave_Transactional_Groups 0
Replicate_Rewrite_DB
Connects_Tried 0
Master_Retry_Count 0
RESET REPLICA ALL;
# End of reset_slave_all_leaks_master_info.test
51 changes: 51 additions & 0 deletions mysql-test/suite/rpl/t/reset_slave_all_leaks_master_info.test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I saw RESET SLAVE already tested somewhere.
Maybe it didn’t cover RESET SLAVE ALL well.

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
--echo #
--echo # MDEV-38497 RESET SLAVE ALL doesn't remove all slave related configurations
--echo #

# Test replica should clear ALL master connection info

--source include/master-slave.inc

connection slave;

STOP REPLICA;
--source include/wait_for_slave_io_to_stop.inc
--source include/wait_for_slave_sql_to_stop.inc
Comment on lines +7 to +13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There’s stop_slave.inc.
Though master-slave.inc has a parameter that skips starting the slave.

But really, since this test doesn’t require a master server or any actual replication work, it could be directly in the main suite.


--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
eval CHANGE MASTER TO
MASTER_HOST='localhost',
MASTER_USER='replssl',
MASTER_PASSWORD='password',
MASTER_PORT=3001,
MASTER_CONNECT_RETRY=7,
MASTER_HEARTBEAT_PERIOD=9,
MASTER_SSL=1,
MASTER_SSL_CA='$MYSQL_TEST_DIR/std_data/cacert.pem',
MASTER_SSL_CAPATH='$MYSQL_TEST_DIR/std_data',
MASTER_SSL_CERT='$MYSQL_TEST_DIR/std_data/client-cert.pem',
MASTER_SSL_KEY='$MYSQL_TEST_DIR/std_data/client-key.pem',
MASTER_SSL_CRL='$MYSQL_TEST_DIR/std_data/crl.pem',
MASTER_SSL_CRLPATH='$MYSQL_TEST_DIR/std_data',
MASTER_SSL_CIPHER='AES256-SHA',
MASTER_SSL_VERIFY_SERVER_CERT=1,
MASTER_RETRY_COUNT=17,
MASTER_USE_GTID=slave_pos,
IGNORE_SERVER_IDS=(123),
DO_DOMAIN_IDS=(19);

#
# Everything must be cleared / set to default values
#
RESET REPLICA ALL;

CHANGE MASTER TO MASTER_HOST='localhost';

--query_vertical SHOW REPLICA STATUS

# Cleanup
RESET REPLICA ALL;

# --source include/rpl_end.inc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Please use SLAVE over REPLICA to match the other tests for the time being.
  • Perhaps the second RESET is for clearing the MASTER_HOST='localhost' part.
    But MTR is okay if you leave certain configurations set to their defaults.
  • Interesting that the CI kept working with rpl_end.inc commented out.
    Well, at least until this rpl.rpl_slave_status you reported on Zulip.


--echo # End of reset_slave_all_leaks_master_info.test
42 changes: 42 additions & 0 deletions sql/rpl_mi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@

static void init_master_log_pos(Master_info* mi);

static void init_ssl_config(Master_info* mi);

static void init_connection_config(Master_info* mi);

static void init_group_counters_config(Master_info* mi);

Master_info::Master_info(LEX_CSTRING *connection_name_arg,
bool is_slave_recovery):
Master_info_file(ignore_server_ids, domain_id_filter.m_domain_ids[0],
Expand Down Expand Up @@ -177,9 +183,45 @@ void Master_info::clear_in_memory_info(bool all)
host[0] = 0; user[0] = 0; password[0] = 0;
domain_id_filter.clear_ids();
reset_dynamic(&ignore_server_ids);
init_ssl_config(this);
init_connection_config(this);
init_group_counters_config(this);
Comment on lines +186 to +188
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The project isn’t just about adding clears to RESET SLAVE, but also checking which one is done where and whether they could’ve been the same.

}
}


void init_ssl_config(Master_info* mi)
{
DBUG_ENTER("init_ssl_config");
mi->master_ssl= 1;
mi->master_ssl_verify_server_cert= 0;
mi->master_ssl_ca= nullptr; mi->master_ssl_capath= nullptr; mi->master_ssl_cert= nullptr;
mi->master_ssl_cipher= nullptr; mi->master_ssl_key= nullptr; mi->master_ssl_crl= nullptr;
mi->master_ssl_crlpath= nullptr;
Comment on lines +198 to +200
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should fix the earlier LTS versions as well.

In either case, this section is unique to a refactor on 12.3.

DBUG_VOID_RETURN;
}


void init_group_counters_config(Master_info* mi)
{
DBUG_ENTER("init_group_counters_config");
mi->total_ddl_groups= 0;
mi->total_non_trans_groups= 0;
mi->total_trans_groups= 0;
DBUG_VOID_RETURN;
}


void init_connection_config(Master_info* mi)
{
DBUG_ENTER("init_connection_config");
mi->connect_retry= 0;
mi->retry_count= 0;
mi->connects_tried= 0;
DBUG_VOID_RETURN;
}


void init_master_log_pos(Master_info* mi)
{
DBUG_ENTER("init_master_log_pos");
Expand Down