Skip to content
/ server Public
Open
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;
include/stop_slave.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 SLAVE ALL;
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root';
SHOW SLAVE STATUS;
Slave_IO_State
Master_Host 127.0.0.1
Master_User root
Master_Port 3306
Connect_Retry 60
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 0
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 30
include/rpl_end.inc
Warnings:
Note 1255 Slave already has been stopped
# End of reset_slave_all_leaks_master_info.test
46 changes: 46 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,46 @@
--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;

source include/stop_slave.inc;

--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 SLAVE ALL;

CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root';

--query_vertical SHOW SLAVE STATUS

--source include/rpl_end.inc

--echo # End of reset_slave_all_leaks_master_info.test
50 changes: 50 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,48 @@ 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.set_default();
mi->retry_count.set_default();
mi->connects_tried= 0;
mi->master_id= 0;
mi->prev_master_id= 0;
mi->received_heartbeats= 0;
DBUG_VOID_RETURN;
}


void init_master_log_pos(Master_info* mi)
{
DBUG_ENTER("init_master_log_pos");
Expand All @@ -191,6 +236,11 @@ void init_master_log_pos(Master_info* mi)
mi->events_queued_since_last_gtid= 0;
mi->gtid_reconnect_event_skip_count= 0;
mi->gtid_event_seen= false;
mi->last_queued_gtid= {};
mi->last_queued_gtid_standalone= false;
mi->do_accept_own_server_id= false;
mi->is_demotion= false;
mi->rows_event_tracker.reset();
DBUG_VOID_RETURN;
}

Expand Down