diff --git a/mysql-test/suite/multi_source/connects_tried.result b/mysql-test/suite/multi_source/connects_tried.result index cf2069a864f..fa92b572b4c 100644 --- a/mysql-test/suite/multi_source/connects_tried.result +++ b/mysql-test/suite/multi_source/connects_tried.result @@ -80,27 +80,36 @@ SELECT * FROM status_after JOIN status_stop USING(Connection_name) WHERE status_stop.Connects_Tried <> status_after.Connects_Tried; Connection_name Connects_Tried Connects_Tried -START SLAVE; -include/wait_for_slave_to_start.inc +include/start_slave.inc # START SLAVE recounts `Connects_Tried` from 1 (for the restarted connection only). CREATE TEMPORARY TABLE status_restart AS SELECT Connection_name, Connects_Tried FROM information_schema.SLAVE_STATUS; SELECT * -FROM status_restart JOIN status_stop USING(Connection_name) +FROM status_stop JOIN status_restart USING(Connection_name) WHERE status_restart.Connects_Tried NOT BETWEEN IF( Connection_name = '', 1, status_stop.Connects_Tried ) AND status_stop.Connects_Tried; Connection_name Connects_Tried Connects_Tried -STOP SLAVE; -include/wait_for_slave_to_stop.inc +include/stop_slave.inc +CHANGE MASTER TO Master_Retry_Count=777; +# Setting `Master_Retry_Count` resets `Connects_Tried` to 0 (for the changed connection only). +CREATE TEMPORARY TABLE status_change AS +SELECT Connection_name, Connects_Tried FROM information_schema.SLAVE_STATUS; +SELECT * +FROM status_restart JOIN status_change USING(Connection_name) +WHERE status_change.Connects_Tried <> +IF(Connection_name = '', 0, status_restart.Connects_Tried); +Connection_name Connects_Tried Connects_Tried +include/start_slave.inc +include/stop_slave.inc RESET SLAVE; # RESET SLAVE resets `Connects_Tried` to 0 (for the resetted connection only). CREATE TEMPORARY TABLE status_reset AS SELECT Connection_name, Connects_Tried FROM information_schema.SLAVE_STATUS; SELECT * -FROM status_reset JOIN status_restart USING(Connection_name) +FROM status_change JOIN status_reset USING(Connection_name) WHERE status_reset.Connects_Tried <> -IF(Connection_name = '', 0, status_restart.Connects_Tried); +IF(Connection_name = '', 0, status_change.Connects_Tried); Connection_name Connects_Tried Connects_Tried # Cleanup RESET SLAVE 'named' ALL; diff --git a/mysql-test/suite/multi_source/connects_tried.test b/mysql-test/suite/multi_source/connects_tried.test index 27f47966979..f8a014a5180 100644 --- a/mysql-test/suite/multi_source/connects_tried.test +++ b/mysql-test/suite/multi_source/connects_tried.test @@ -122,27 +122,37 @@ SELECT * FROM status_after JOIN status_stop USING(Connection_name) WHERE status_stop.Connects_Tried <> status_after.Connects_Tried; -START SLAVE; ---source include/wait_for_slave_to_start.inc +--source include/start_slave.inc --echo # START SLAVE recounts `Connects_Tried` from 1 (for the restarted connection only). CREATE TEMPORARY TABLE status_restart AS SELECT Connection_name, Connects_Tried FROM information_schema.SLAVE_STATUS; SELECT * - FROM status_restart JOIN status_stop USING(Connection_name) + FROM status_stop JOIN status_restart USING(Connection_name) WHERE status_restart.Connects_Tried NOT BETWEEN IF( Connection_name = '', 1, status_stop.Connects_Tried ) AND status_stop.Connects_Tried; -STOP SLAVE; ---source include/wait_for_slave_to_stop.inc +--source include/stop_slave.inc +# MDEV-36340 Master_Retry_Count should never be less than Connects_Tried +CHANGE MASTER TO Master_Retry_Count=777; +--echo # Setting `Master_Retry_Count` resets `Connects_Tried` to 0 (for the changed connection only). +CREATE TEMPORARY TABLE status_change AS + SELECT Connection_name, Connects_Tried FROM information_schema.SLAVE_STATUS; +SELECT * + FROM status_restart JOIN status_change USING(Connection_name) + WHERE status_change.Connects_Tried <> + IF(Connection_name = '', 0, status_restart.Connects_Tried); + +--source include/start_slave.inc # build up Connects_Tried again +--source include/stop_slave.inc RESET SLAVE; --echo # RESET SLAVE resets `Connects_Tried` to 0 (for the resetted connection only). CREATE TEMPORARY TABLE status_reset AS SELECT Connection_name, Connects_Tried FROM information_schema.SLAVE_STATUS; SELECT * - FROM status_reset JOIN status_restart USING(Connection_name) + FROM status_change JOIN status_reset USING(Connection_name) WHERE status_reset.Connects_Tried <> - IF(Connection_name = '', 0, status_restart.Connects_Tried); + IF(Connection_name = '', 0, status_change.Connects_Tried); --echo # Cleanup RESET SLAVE 'named' ALL; diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 7174d8ae7e2..3f41bd44f7f 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -4052,7 +4052,10 @@ bool change_master(THD* thd, Master_info* mi, bool *master_info_added) if (lex_mi->connect_retry) mi->connect_retry = lex_mi->connect_retry; if (lex_mi->retry_count) + { mi->retry_count= lex_mi->retry_count; + mi->connects_tried= 0; + } if (lex_mi->heartbeat_opt != LEX_MASTER_INFO::LEX_MI_UNCHANGED) mi->heartbeat_period = lex_mi->heartbeat_period; else