diff --git a/mysql-test/include/check-testcase.inc b/mysql-test/include/check-testcase.inc index 25990c1a9e379..4ae0da30d7bba 100644 --- a/mysql-test/include/check-testcase.inc +++ b/mysql-test/include/check-testcase.inc @@ -74,10 +74,12 @@ if ($tmp) --echo Slave_Non_Transactional_Groups # --echo Slave_Transactional_Groups # --echo Replicate_Rewrite_DB # + --echo Connects_Tried # + --echo Primary_Retry_Count # } if (!$tmp) { # Note: after WL#5177, fields 13-18 shall not be filtered-out. - --replace_column 4 # 5 # 6 # 7 # 8 # 9 # 10 # 13 # 14 # 15 # 16 # 17 # 18 # 22 # 23 # 24 # 25 # 26 # 40 # 41 # 42 # 44 # 51 # 52 # 53 # 54 # + --replace_column 4 # 5 # 6 # 7 # 8 # 9 # 10 # 13 # 14 # 15 # 16 # 17 # 18 # 22 # 23 # 24 # 25 # 26 # 40 # 41 # 42 # 44 # 51 # 52 # 53 # 54 # 55 # 56 # query_vertical SHOW SLAVE STATUS; } @@ -161,4 +163,3 @@ if (`SELECT COUNT(*)=1 FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME = 'wsre } --enable_query_log - diff --git a/mysql-test/suite/funcs_1/r/is_columns_is.result b/mysql-test/suite/funcs_1/r/is_columns_is.result index e5c938c1e480c..e985af18f1375 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is.result @@ -390,6 +390,7 @@ def information_schema SESSION_STATUS VARIABLE_VALUE 2 NULL NO varchar 4096 1228 def information_schema SESSION_VARIABLES VARIABLE_NAME 1 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(64) select NEVER NULL NO NO def information_schema SESSION_VARIABLES VARIABLE_VALUE 2 NULL NO varchar 4096 12288 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(4096) select NEVER NULL NO NO def information_schema SLAVE_STATUS Connection_name 1 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(64) select NEVER NULL NO NO +def information_schema SLAVE_STATUS Connects_Tried 66 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select NEVER NULL NO NO def information_schema SLAVE_STATUS Connect_Retry 7 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) select NEVER NULL NO NO def information_schema SLAVE_STATUS Executed_log_entries 59 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned select NEVER NULL NO NO def information_schema SLAVE_STATUS Exec_Master_Log_Pos 24 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(10) unsigned select NEVER NULL NO NO @@ -419,6 +420,7 @@ def information_schema SLAVE_STATUS Master_SSL_Verify_Server_Cert 36 NULL NO var def information_schema SLAVE_STATUS Master_User 5 NULL YES varchar 384 1152 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(384) select NEVER NULL NO NO def information_schema SLAVE_STATUS Max_relay_log_size 58 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(10) unsigned select NEVER NULL NO NO def information_schema SLAVE_STATUS Parallel_Mode 49 NULL NO varchar 15 45 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(15) select NEVER NULL NO NO +def information_schema SLAVE_STATUS Primary_Retry_Count 67 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select NEVER NULL NO NO def information_schema SLAVE_STATUS Read_Master_Log_Pos 9 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(10) unsigned select NEVER NULL NO NO def information_schema SLAVE_STATUS Relay_Log_File 10 NULL NO varchar 512 1536 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(512) select NEVER NULL NO NO def information_schema SLAVE_STATUS Relay_Log_Pos 11 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(10) unsigned select NEVER NULL NO NO @@ -1129,6 +1131,8 @@ NULL information_schema SLAVE_STATUS Slave_heartbeat_period float NULL NULL NULL NULL information_schema SLAVE_STATUS Master_last_event_time datetime NULL NULL NULL NULL datetime NULL information_schema SLAVE_STATUS Slave_last_event_time datetime NULL NULL NULL NULL datetime NULL information_schema SLAVE_STATUS Master_Slave_time_diff bigint NULL NULL NULL NULL bigint(10) +NULL information_schema SLAVE_STATUS Connects_Tried bigint NULL NULL NULL NULL bigint(20) unsigned +NULL information_schema SLAVE_STATUS Primary_Retry_Count bigint NULL NULL NULL NULL bigint(20) unsigned NULL information_schema SPATIAL_REF_SYS SRID smallint NULL NULL NULL NULL smallint(5) 3.0000 information_schema SPATIAL_REF_SYS AUTH_NAME varchar 512 1536 utf8mb3 utf8mb3_general_ci varchar(512) NULL information_schema SPATIAL_REF_SYS AUTH_SRID int NULL NULL NULL NULL int(5) diff --git a/mysql-test/suite/multi_source/info_logs.result b/mysql-test/suite/multi_source/info_logs.result index 4dca25b8fc7bb..8f3ada51a6036 100644 --- a/mysql-test/suite/multi_source/info_logs.result +++ b/mysql-test/suite/multi_source/info_logs.result @@ -94,17 +94,17 @@ MASTER 2.2 # EOF # show all slaves status; -Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Replicate_Rewrite_DB Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos Master_last_event_time Slave_last_event_time Master_Slave_time_diff - Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 relay.000002 master-bin.000001 Yes Yes 0 0 None 0 Yes 0 No 0 0 1 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 7 0 60.000 NULL NULL NULL -MASTER 2.2 Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 relay-master@00202@002e2.000002 master-bin.000001 Yes Yes 0 0 None 0 Yes 0 No 0 0 2 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 7 0 60.000 NULL NULL NULL +Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Replicate_Rewrite_DB Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos Master_last_event_time Slave_last_event_time Master_Slave_time_diff Connects_Tried Primary_Retry_Count + Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 relay.000002 master-bin.000001 Yes Yes 0 0 None 0 Yes 0 No 0 0 1 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 7 0 60.000 NULL NULL NULL 1 100000 +MASTER 2.2 Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 relay-master@00202@002e2.000002 master-bin.000001 Yes Yes 0 0 None 0 Yes 0 No 0 0 2 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 7 0 60.000 NULL NULL NULL 1 100000 include/wait_for_slave_to_start.inc set default_master_connection = 'MASTER 2.2'; include/wait_for_slave_to_start.inc set default_master_connection = ''; show all slaves status; -Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Replicate_Rewrite_DB Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos Master_last_event_time Slave_last_event_time Master_Slave_time_diff - Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 relay.000004 master-bin.000001 Yes Yes 0 0 None 0 Yes 0 No 0 0 1 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 6 0 60.000 NULL NULL NULL -MASTER 2.2 Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 relay-master@00202@002e2.000004 master-bin.000001 Yes Yes 0 0 None 0 Yes 0 No 0 0 2 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 6 0 60.000 NULL NULL NULL +Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Replicate_Rewrite_DB Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos Master_last_event_time Slave_last_event_time Master_Slave_time_diff Connects_Tried Primary_Retry_Count + Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 relay.000004 master-bin.000001 Yes Yes 0 0 None 0 Yes 0 No 0 0 1 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 6 0 60.000 NULL NULL NULL 1 100000 +MASTER 2.2 Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 relay-master@00202@002e2.000004 master-bin.000001 Yes Yes 0 0 None 0 Yes 0 No 0 0 2 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 6 0 60.000 NULL NULL NULL 1 100000 # # List of files matching '*info*' pattern # after slave server restart diff --git a/mysql-test/suite/multi_source/multi_source_slave_alias_replica.result b/mysql-test/suite/multi_source/multi_source_slave_alias_replica.result index 182d9687cb922..0dc184458021f 100644 --- a/mysql-test/suite/multi_source/multi_source_slave_alias_replica.result +++ b/mysql-test/suite/multi_source/multi_source_slave_alias_replica.result @@ -85,6 +85,8 @@ Gtid_Slave_Pos Master_last_event_time NULL Slave_last_event_time NULL Master_Slave_time_diff NULL +Connects_Tried 1 +Primary_Retry_Count 100000 Connection_name slave2 Slave_SQL_State Slave has read all relay log; waiting for more updates Slave_IO_State Waiting for master to send event @@ -150,6 +152,8 @@ Gtid_Slave_Pos Master_last_event_time NULL Slave_last_event_time NULL Master_Slave_time_diff NULL +Connects_Tried 1 +Primary_Retry_Count 100000 "Command: STOP ALL SLAVES --> STOP ALL REPLICAS" STOP ALL REPLICAS; Warnings: diff --git a/mysql-test/suite/multi_source/reset_slave.result b/mysql-test/suite/multi_source/reset_slave.result index c859c5d7eb3bb..10efb427e469a 100644 --- a/mysql-test/suite/multi_source/reset_slave.result +++ b/mysql-test/suite/multi_source/reset_slave.result @@ -13,15 +13,15 @@ insert into t1 values (1),(2); connection slave; stop slave 'master1'; show slave 'master1' status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Replicate_Rewrite_DB - 127.0.0.1 root MYPORT_1 60 master-bin.000001 mysqld-relay-bin-master1.000002 master-bin.000001 No No 0 0 None 0 Yes NULL No 0 0 1 Slave_Pos 0-1-3 optimistic 0 NULL 2 1 0 +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Replicate_Rewrite_DB Connects_Tried Primary_Retry_Count + 127.0.0.1 root MYPORT_1 60 master-bin.000001 mysqld-relay-bin-master1.000002 master-bin.000001 No No 0 0 None 0 Yes NULL No 0 0 1 Slave_Pos 0-1-3 optimistic 0 NULL 2 1 0 1 100000 mysqld-relay-bin-master1.000001 mysqld-relay-bin-master1.000002 mysqld-relay-bin-master1.index reset slave 'master1'; show slave 'master1' status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Replicate_Rewrite_DB - 127.0.0.1 root MYPORT_1 60 4 No No 0 0 0 None 0 Yes NULL No 0 0 1 Slave_Pos optimistic 0 NULL 2 1 0 +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Replicate_Rewrite_DB Connects_Tried Primary_Retry_Count + 127.0.0.1 root MYPORT_1 60 4 No No 0 0 0 None 0 Yes NULL No 0 0 1 Slave_Pos optimistic 0 NULL 2 1 0 1 100000 reset slave 'master1' all; show slave 'master1' status; ERROR HY000: There is no master connection 'master1' diff --git a/mysql-test/suite/multi_source/simple.result b/mysql-test/suite/multi_source/simple.result index 465490e9f99ae..8f5f5cf7d680c 100644 --- a/mysql-test/suite/multi_source/simple.result +++ b/mysql-test/suite/multi_source/simple.result @@ -83,6 +83,8 @@ Gtid_Slave_Pos Master_last_event_time NULL Slave_last_event_time NULL Master_Slave_time_diff NULL +Connects_Tried 1 +Primary_Retry_Count 100000 Connection_name slave2 Slave_SQL_State Slave has read all relay log; waiting for more updates Slave_IO_State Waiting for master to send event @@ -148,6 +150,8 @@ Gtid_Slave_Pos Master_last_event_time NULL Slave_last_event_time NULL Master_Slave_time_diff NULL +Connects_Tried 1 +Primary_Retry_Count 100000 # # MDEV:16437: merge 5.7 P_S replication instrumentation and tables # @@ -269,6 +273,8 @@ Slave_DDL_Groups 0 Slave_Non_Transactional_Groups 0 Slave_Transactional_Groups 0 Replicate_Rewrite_DB +Connects_Tried 1 +Primary_Retry_Count 100000 reset slave 'slave1'; show all slaves status; Connection_name slave1 @@ -336,6 +342,8 @@ Gtid_Slave_Pos Master_last_event_time NULL Slave_last_event_time NULL Master_Slave_time_diff NULL +Connects_Tried 1 +Primary_Retry_Count 100000 Connection_name slave2 Slave_SQL_State Slave has read all relay log; waiting for more updates Slave_IO_State Waiting for master to send event @@ -401,6 +409,8 @@ Gtid_Slave_Pos Master_last_event_time NULL Slave_last_event_time NULL Master_Slave_time_diff NULL +Connects_Tried 1 +Primary_Retry_Count 100000 reset slave 'slave1' all; show all slaves status; Connection_name slave2 @@ -468,6 +478,8 @@ Gtid_Slave_Pos Master_last_event_time NULL Slave_last_event_time NULL Master_Slave_time_diff NULL +Connects_Tried 1 +Primary_Retry_Count 100000 stop all slaves; Warnings: Note 1938 SLAVE 'slave2' stopped @@ -537,6 +549,8 @@ Gtid_Slave_Pos Master_last_event_time NULL Slave_last_event_time NULL Master_Slave_time_diff NULL +Connects_Tried 1 +Primary_Retry_Count 100000 stop all slaves; # # MDEV-21858: START/STOP ALL SLAVES does not return access errors diff --git a/mysql-test/suite/multi_source/syntax.result b/mysql-test/suite/multi_source/syntax.result index 7475ff76e587d..d8730d14847df 100644 --- a/mysql-test/suite/multi_source/syntax.result +++ b/mysql-test/suite/multi_source/syntax.result @@ -1,11 +1,11 @@ include/master-slave.inc [connection master] show slave status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Replicate_Rewrite_DB +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Replicate_Rewrite_DB Connects_Tried Primary_Retry_Count show slave '' status; -Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Replicate_Rewrite_DB +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Replicate_Rewrite_DB Connects_Tried Primary_Retry_Count show all slaves status; -Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Replicate_Rewrite_DB Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos Master_last_event_time Slave_last_event_time Master_Slave_time_diff +Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Replicate_Rewrite_DB Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos Master_last_event_time Slave_last_event_time Master_Slave_time_diff Connects_Tried Primary_Retry_Count # # Check error handling # diff --git a/mysql-test/suite/rpl/r/rpl_connects_tried.result b/mysql-test/suite/rpl/r/rpl_connects_tried.result new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/mysql-test/suite/rpl/r/rpl_show_slave_status.result b/mysql-test/suite/rpl/r/rpl_show_slave_status.result index e32b2f554cee4..fa8aab513e83a 100644 --- a/mysql-test/suite/rpl/r/rpl_show_slave_status.result +++ b/mysql-test/suite/rpl/r/rpl_show_slave_status.result @@ -67,6 +67,8 @@ Slave_DDL_Groups # Slave_Non_Transactional_Groups # Slave_Transactional_Groups # Replicate_Rewrite_DB # +Connects_Tried # +Primary_Retry_Count # * * When modifying this test after adding a column to SHOW SLAVE STATUS, * _only_ additions at the end are allowed, the column number of existing diff --git a/mysql-test/suite/rpl/t/rpl_connects_tried.test b/mysql-test/suite/rpl/t/rpl_connects_tried.test new file mode 100644 index 0000000000000..b9f5dd3163030 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_connects_tried.test @@ -0,0 +1,52 @@ +# This test is based on `rpl_get_master_version_and_clock`. +--SOURCE include/have_debug.inc +--SOURCE include/have_debug_sync.inc +--SOURCE include/have_log_bin.inc # The test is agnostic of binlog formats. +--SOURCE include/master-slave.inc + +--LET $rpl_server_number= 1 +--LET $status_items= Slave_IO_Running + +#--CALL mtr.add_suppression("Slave I/O: Master command COM_REGISTER_SLAVE failed: .*") +#--CALL mtr.add_suppression("Slave I/O: .* failed with error: Lost connection to MySQL server at 'reading initial communication packet'") +#--CALL mtr.add_suppression("Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; .*") +#--CALL mtr.add_suppression("Slave I/O thread .* register on master") + +--CONNECTION slave +--SOURCE include/stop_slave.inc + +--LET @original_master_connect_retry= `SELECT master_connect_retry FROM information_schema.SLAVE_STATUS` +CHANGE MASTER TO master_connect_retry= 1; +--LET $original_dbug= @@GLOBAL.debug_dbug +SET @@GLOBAL.debug_dbug= "d,debug_lock.before_get_UNIX_TIMESTAMP"; + +--SOURCE include/start_slave.inc +# The replica will hang in `get_master_version_and_clock`. + +--SOURCE include/rpl_stop_server.inc # shut the primary down +--CONNECTION slave +SET DEBUG_SYNC= "now SIGNAL signal.get_unix_timestamp"; +SET @@GLOBAL.debug_dbug= original_dbug; + +--LET $slave_io_error_is_nonfatal= 1 +# '2013' CR_SERVER_LOST +# '2003' CR_CONN_HOST_ERROR +# '2002' CR_CONNECTION_ERROR +# '2006' CR_SERVER_GONE_ERROR +# '1053' ER_SERVER_SHUTDOWN +--LET $slave_io_errno= 1053, 2002, 2003, 2006, 2013 +--SOURCE include/wait_for_slave_io_error.inc + +SOURCE include/show_slave_status.inc; +SLEEP 2; +SOURCE include/show_slave_status.inc; + +--SOURCE include/rpl_start_server.inc +--CONECTION slave +CHANGE MASTER TO master_connect_retry= 1; +# `wait_for_slave_io_to_start.inc` fails if the IO thread has an error. +--LET $slave_param= Slave_IO_Running +--LET $slave_param_value= Yes +--SOURCE include/wait_for_slave_param.inc +#--SET DEBUG_SYNC= 'RESET' +SOURCE include/rpl_end.inc; diff --git a/mysql-test/suite/rpl/t/rpl_heartbeat_debug.test b/mysql-test/suite/rpl/t/rpl_heartbeat_debug.test index e593786655bcb..8b1d7517b2e1e 100644 --- a/mysql-test/suite/rpl/t/rpl_heartbeat_debug.test +++ b/mysql-test/suite/rpl/t/rpl_heartbeat_debug.test @@ -5,7 +5,7 @@ --disable_query_log CALL mtr.add_suppression('SET @master_heartbeat_period to master failed with error'); -CALL mtr.add_suppression('Master command COM_REGISTER_SLAVE failed: failed registering on master, reconnecting to try again'); +CALL mtr.add_suppression('Master command COM_REGISTER_SLAVE failed: Replica I/O thread: register on primary failed, reconnecting to try again'); call mtr.add_suppression("Could not read packet:.* errno: 11"); --enable_query_log diff --git a/mysql-test/suite/rpl/t/rpl_show_slave_status.test b/mysql-test/suite/rpl/t/rpl_show_slave_status.test index f4bbb5faeabf1..2bc21ae671bf5 100644 --- a/mysql-test/suite/rpl/t/rpl_show_slave_status.test +++ b/mysql-test/suite/rpl/t/rpl_show_slave_status.test @@ -14,7 +14,7 @@ --echo * --connection slave ---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # 17 # 18 # 19 # 20 # 21 # 22 # 23 # 24 # 25 # 26 # 27 # 28 # 29 # 30 # 31 # 32 # 33 # 34 # 35 # 36 # 37 # 38 # 39 # 40 # 41 # 42 # 43 # 44 # 45 # 46 # 47 # 48 # 49 # 50 # 51 # 52 # 53 # 54 # +--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 11 # 12 # 13 # 14 # 15 # 16 # 17 # 18 # 19 # 20 # 21 # 22 # 23 # 24 # 25 # 26 # 27 # 28 # 29 # 30 # 31 # 32 # 33 # 34 # 35 # 36 # 37 # 38 # 39 # 40 # 41 # 42 # 43 # 44 # 45 # 46 # 47 # 48 # 49 # 50 # 51 # 52 # 53 # 54 # 55 # 56 # query_vertical SHOW SLAVE STATUS; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 89d9cc646c8ca..f69d6fcfc5ae0 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -780,7 +780,7 @@ File_parser_dummy_hook file_parser_dummy_hook; /* replication parameters, if master_host is not NULL, we are a slave */ uint report_port= 0; -ulong master_retry_count=0; +ulong master_retry_count=100000; char *master_info_file; char *relay_log_info_file, *report_user, *report_password, *report_host; char *opt_relay_logname = 0, *opt_relaylog_index_name=0; @@ -6820,7 +6820,7 @@ struct my_option my_long_options[]= {"master-retry-count", 0, "The number of tries the slave will make to connect to the master before giving up", &master_retry_count, &master_retry_count, 0, GET_ULONG, - REQUIRED_ARG, 100000, 0, 0, 0, 0, 0}, + REQUIRED_ARG, static_cast(master_retry_count), 0, 0, 0, 0, 0}, #ifdef HAVE_REPLICATION {"init-rpl-role", 0, "Set the replication role", &rpl_status, &rpl_status, &rpl_role_typelib, diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc index c3245ba0c1088..4172e93c45d00 100644 --- a/sql/rpl_mi.cc +++ b/sql/rpl_mi.cc @@ -35,7 +35,10 @@ Master_info::Master_info(LEX_CSTRING *connection_name_arg, ssl(1), ssl_verify_server_cert(1), fd(-1), io_thd(0), rli(is_slave_recovery), port(MYSQL_PORT), checksum_alg_before_fd(BINLOG_CHECKSUM_ALG_UNDEF), - connect_retry(DEFAULT_CONNECT_RETRY), inited(0), abort_slave(0), + connect_retry(DEFAULT_CONNECT_RETRY), + retry_count(master_retry_count), + connects_tried(0), + inited(0), abort_slave(0), slave_running(MYSQL_SLAVE_NOT_RUN), slave_run_id(0), clock_diff_with_master(0), sync_counter(0), heartbeat_period(0), received_heartbeats(0), diff --git a/sql/rpl_mi.h b/sql/rpl_mi.h index 37a5fc30099c9..de8a422ae9498 100644 --- a/sql/rpl_mi.h +++ b/sql/rpl_mi.h @@ -253,7 +253,12 @@ class Master_info : public Slave_reporting_capability @@global.binlog_checksum and deactivated once FD has been received. */ enum_binlog_checksum_alg checksum_alg_before_fd; + /** pause duration between each connection retry */ uint connect_retry; + /** replica-specific @ref master_retry_count */ + ulong retry_count; + /** count of connects the most-recent (or the current) connection has tried */ + ulong connects_tried; #ifndef DBUG_OFF int events_till_disconnect; diff --git a/sql/slave.cc b/sql/slave.cc index e16834a387da3..1d748789a245a 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -102,57 +102,33 @@ LEX_CSTRING default_master_connection_name= { (char*) "", 0 }; int disconnect_slave_event_count = 0, abort_slave_event_count = 0; -enum enum_slave_reconnect_actions -{ - SLAVE_RECON_ACT_REG= 0, - SLAVE_RECON_ACT_DUMP= 1, - SLAVE_RECON_ACT_EVENT= 2, - SLAVE_RECON_ACT_MAX -}; - -enum enum_slave_reconnect_messages -{ - SLAVE_RECON_MSG_WAIT= 0, - SLAVE_RECON_MSG_KILLED_WAITING= 1, - SLAVE_RECON_MSG_AFTER= 2, - SLAVE_RECON_MSG_FAILED= 3, - SLAVE_RECON_MSG_COMMAND= 4, - SLAVE_RECON_MSG_KILLED_AFTER= 5, - SLAVE_RECON_MSG_MAX -}; - -static const char *reconnect_messages[SLAVE_RECON_ACT_MAX][SLAVE_RECON_MSG_MAX]= +namespace reconnect_messages { + static const struct messages { - "Waiting to reconnect after a failed registration on master", - "Slave I/O thread killed while waiting to reconnect after a failed \ -registration on master", - "Reconnecting after a failed registration on master", - "failed registering on master, reconnecting to try again, \ -log '%s' at position %llu%s", + const char *proc_info, //< full message + *action, //< simple present tense + *command; + } + reg= + { + "Reconnecting after a failed registration on primary", + "register on primary", "COM_REGISTER_SLAVE", - "Slave I/O thread killed during or after reconnect" }, + dump= { - "Waiting to reconnect after a failed binlog dump request", - "Slave I/O thread killed while retrying master dump", "Reconnecting after a failed binlog dump request", - "failed dump request, reconnecting to try again, log '%s' at position %llu%s", + "binlog dump request", "COM_BINLOG_DUMP", - "Slave I/O thread killed during or after reconnect" }, + event= { - "Waiting to reconnect after a failed master event read", - "Slave I/O thread killed while waiting to reconnect after a failed read", - "Reconnecting after a failed master event read", - "Slave I/O thread: Failed reading log event, reconnecting to retry, \ -log '%s' at position %llu%s", - "", - "Slave I/O thread killed during or after a reconnect done to recover from \ -failed read" - } -}; - + "Reconnecting after a failed primary event read", + "primary event read", + nullptr, + }; +} typedef enum { SLAVE_THD_IO, SLAVE_THD_SQL} SLAVE_THD_TYPE; @@ -1317,14 +1293,15 @@ void end_slave() DBUG_VOID_RETURN; } +/** @return whether the replica's Master_info is marked as killed */ static bool io_slave_killed(Master_info* mi) { DBUG_ENTER("io_slave_killed"); - DBUG_ASSERT(mi->slave_running); // tracking buffer overrun - if (mi->abort_slave || mi->io_thd->killed) + bool is_io_slave_killed= mi->abort_slave || mi->io_thd->killed; + if (is_io_slave_killed) DBUG_PRINT("info", ("killed")); - DBUG_RETURN(mi->abort_slave || mi->io_thd->killed); + DBUG_RETURN(is_io_slave_killed); } /** @@ -2609,10 +2586,6 @@ when it try to get the value of TIME_ZONE global variable from master."; DBUG_RETURN(0); network_err: - if (master_res) - mysql_free_result(master_res); - DBUG_RETURN(2); - slave_killed_err: if (master_res) mysql_free_result(master_res); @@ -3160,6 +3133,10 @@ void store_master_info(THD *thd, Master_info *mi, TABLE *table, (*field++)->set_null(); (*field++)->set_null(); } + + (*field++)->store(static_cast(mi->connects_tried), true); + (*field++)->store(static_cast(mi->retry_count), true); + mysql_mutex_unlock(&mi->rli.err_lock); mysql_mutex_unlock(&mi->err_lock); mysql_mutex_unlock(&mi->rli.data_lock); @@ -4381,62 +4358,49 @@ on this slave.\ } +/** Return io_slave_killed(); if it's `true`, also log the given `info`. */ static bool check_io_slave_killed(Master_info *mi, const char *info) { - if (io_slave_killed(mi)) - { - if (info && global_system_variables.log_warnings) - sql_print_information("%s", info); - return TRUE; - } - return FALSE; + bool is_io_slave_killed= io_slave_killed(mi); + if (is_io_slave_killed && info && global_system_variables.log_warnings) + sql_print_information("%s", info); + return is_io_slave_killed; } /** @brief Try to reconnect slave IO thread. - @details Terminates current connection to master, sleeps for - @c mi->connect_retry msecs and initiates new connection with - @c safe_reconnect(). Variable pointed by @c retry_count is increased - - if it exceeds @c master_retry_count then connection is not re-established - and function signals error. + @details Terminates current connection to master + and initiates new connection with safe_reconnect(), which sleeps for + @c mi->connect_retry msecs and increases @c mi->connects_tried for each + attempt - if it exceeds @c mi->retry_count then connection is not + re-established and function signals error. Unless @c suppres_warnings is TRUE, a warning is put in the server error log when reconnecting. The warning message and messages used to report errors - are taken from @c messages array. In case @c master_retry_count is exceeded, - no messages are added to the log. + are built from @c messages struct. @param[in] thd Thread context. @param[in] mysql MySQL connection. @param[in] mi Master connection information. - @param[in,out] retry_count Number of attempts to reconnect. @param[in] suppress_warnings TRUE when a normal net read timeout has caused to reconnecting. - @param[in] messages Messages to print/log, see - reconnect_messages[] array. + @param[in] messages Message components to print/log, + see namespace reconnect_messages. @retval 0 OK. @retval 1 There was an error. */ static int try_to_reconnect(THD *thd, MYSQL *mysql, Master_info *mi, - uint *retry_count, bool suppress_warnings, - const char *messages[SLAVE_RECON_MSG_MAX]) + bool suppress_warnings, + const struct reconnect_messages::messages *messages) { mi->slave_running= MYSQL_SLAVE_RUN_NOT_CONNECT; - thd->proc_info= messages[SLAVE_RECON_MSG_WAIT]; #ifdef SIGNAL_WITH_VIO_CLOSE thd->clear_active_vio(); #endif end_server(mysql); - if ((*retry_count)++) - { - if (*retry_count > master_retry_count) - return 1; // Don't retry forever - slave_sleep(thd, mi->connect_retry, io_slave_killed, mi); - } - if (check_io_slave_killed(mi, messages[SLAVE_RECON_MSG_KILLED_WAITING])) - return 1; - thd->proc_info = messages[SLAVE_RECON_MSG_AFTER]; + thd->proc_info= messages->proc_info; if (!suppress_warnings) { char buf[256]; @@ -4445,36 +4409,35 @@ static int try_to_reconnect(THD *thd, MYSQL *mysql, Master_info *mi, { tmp.append(STRING_WITH_LEN("; GTID position '")); mi->gtid_current_pos.append_to_string(&tmp); - if (mi->events_queued_since_last_gtid == 0) - tmp.append(STRING_WITH_LEN("'")); - else + tmp.append('\''); + if (mi->events_queued_since_last_gtid) { - tmp.append(STRING_WITH_LEN("', GTID event skip ")); + tmp.append(STRING_WITH_LEN(", GTID event skip ")); tmp.append_ulonglong((ulonglong)mi->events_queued_since_last_gtid); } } - my_snprintf(buf, sizeof(buf), messages[SLAVE_RECON_MSG_FAILED], - IO_RPL_LOG_NAME, mi->master_log_pos, + my_snprintf(buf, sizeof(buf), "Replica I/O thread: %s failed, " + "reconnecting to try again, log '%s' at position %llu%s", + messages->action, IO_RPL_LOG_NAME, mi->master_log_pos, tmp.c_ptr_safe()); /* Raise a warining during registering on master/requesting dump. Log a message reading event. */ - if (messages[SLAVE_RECON_MSG_COMMAND][0]) - { + if (messages->command) mi->report(WARNING_LEVEL, ER_SLAVE_MASTER_COM_FAILURE, NULL, ER_THD(thd, ER_SLAVE_MASTER_COM_FAILURE), - messages[SLAVE_RECON_MSG_COMMAND], buf); - } + messages->command, buf); else - { sql_print_information("%s", buf); - } } if (safe_reconnect(thd, mysql, mi, 1) || io_slave_killed(mi)) { if (global_system_variables.log_warnings) - sql_print_information("%s", messages[SLAVE_RECON_MSG_KILLED_AFTER]); + sql_print_information( + "Slave I/O thread killed while reconnecting after %s failed", + messages->action + ); return 1; } repl_semisync_slave.slave_reconnect(mi); @@ -4496,7 +4459,6 @@ pthread_handler_t handle_slave_io(void *arg) MYSQL *mysql; Master_info *mi = (Master_info*)arg; Relay_log_info *rli= &mi->rli; - uint retry_count; bool suppress_warnings; int ret; rpl_io_thread_info io_info; @@ -4510,7 +4472,6 @@ pthread_handler_t handle_slave_io(void *arg) DBUG_ASSERT(mi->inited); mysql= NULL ; - retry_count= 0; thd= new THD(next_thread_id()); // note that contructor of THD uses DBUG_ ! @@ -4660,8 +4621,8 @@ pthread_handler_t handle_slave_io(void *arg) Try to reconnect because the error was caused by a transient network problem */ - if (try_to_reconnect(thd, mysql, mi, &retry_count, suppress_warnings, - reconnect_messages[SLAVE_RECON_ACT_REG])) + if (try_to_reconnect(thd, mysql, mi, suppress_warnings, + &reconnect_messages::reg)) goto err; goto connected; @@ -4677,8 +4638,8 @@ pthread_handler_t handle_slave_io(void *arg) "while registering slave on master")) { sql_print_error("Slave I/O thread couldn't register on master"); - if (try_to_reconnect(thd, mysql, mi, &retry_count, suppress_warnings, - reconnect_messages[SLAVE_RECON_ACT_REG])) + if (try_to_reconnect(thd, mysql, mi, suppress_warnings, + &reconnect_messages::reg)) goto err; } else @@ -4695,7 +4656,7 @@ pthread_handler_t handle_slave_io(void *arg) DBUG_PRINT("info",("Starting reading binary log from master")); thd->set_command(COM_SLAVE_IO); - while (!io_slave_killed(mi)) + if (!io_slave_killed(mi)) { const uchar *event_buf; @@ -4704,8 +4665,8 @@ pthread_handler_t handle_slave_io(void *arg) { sql_print_error("Failed on request_dump()"); if (check_io_slave_killed(mi, NullS) || - try_to_reconnect(thd, mysql, mi, &retry_count, suppress_warnings, - reconnect_messages[SLAVE_RECON_ACT_DUMP])) + try_to_reconnect(thd, mysql, mi, suppress_warnings, + &reconnect_messages::dump)) goto err; goto connected; } @@ -4763,13 +4724,12 @@ Stopping slave I/O thread due to out-of-memory error from master"); "%s", ER_THD(thd, ER_OUT_OF_RESOURCES)); goto err; } - if (try_to_reconnect(thd, mysql, mi, &retry_count, suppress_warnings, - reconnect_messages[SLAVE_RECON_ACT_EVENT])) + if (try_to_reconnect(thd, mysql, mi, suppress_warnings, + &reconnect_messages::event)) goto err; goto connected; } // if (event_len == packet_error) - retry_count=0; // ok event, reset retry counter thd->set_time_for_next_stage(); THD_STAGE_INFO(thd, stage_queueing_master_event_to_the_relay_log); event_buf= mysql->net.read_pos + 1; @@ -6949,21 +6909,21 @@ static int safe_connect(THD* thd, MYSQL* mysql, Master_info* mi) } -/* - SYNPOSIS - connect_to_master() - - IMPLEMENTATION - Try to connect until successful or slave killed or we have retried - master_retry_count times +/** + @brief Re/connect to the primary + @details + After preparations, this repeatedly calls the low-level connection function + up to mi->retry_count times until success or when the replica's killed. + Logs describe either config mistakes or generic connection statuses. + @param reconnect whether this is a reconnection or a new first-time connection + @return errno: 1 if error or 0 if successful */ - static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi, bool reconnect, bool suppress_warnings) { int slave_was_killed; - int last_errno= -2; // impossible error - ulong err_count=0; + unsigned int last_errno= 0; // initialize with not-error + mi->connects_tried= 0; // reset retry counter my_bool my_true= 1; DBUG_ENTER("connect_to_master"); set_slave_max_allowed_packet(thd, mysql); @@ -7023,13 +6983,13 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi, "terminated."); DBUG_RETURN(1); } - while (!(slave_was_killed = io_slave_killed(mi)) && - (reconnect ? mysql_reconnect(mysql) != 0 : - mysql_real_connect(mysql, mi->host, mi->user, mi->password, 0, - mi->port, 0, client_flag) == 0)) + while (!(slave_was_killed= io_slave_killed(mi)) && + (reconnect ? mysql_reconnect(mysql) : + !mysql_real_connect(mysql, mi->host, mi->user, mi->password, 0, + mi->port, 0, client_flag))) { /* Don't repeat last error */ - if ((int)mysql_errno(mysql) != last_errno && !io_slave_killed(mi)) + if (mysql_errno(mysql) != last_errno) { last_errno=mysql_errno(mysql); suppress_warnings= 0; @@ -7038,16 +6998,10 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi, " - retry-time: %d maximum-retries: %lu message: %s", (reconnect ? "reconnecting" : "connecting"), mi->user, mi->host, mi->port, - mi->connect_retry, master_retry_count, + mi->connect_retry, mi->retry_count, mysql_error(mysql)); } - /* - By default we try forever. The reason is that failure will trigger - master election, so if the user did not set master_retry_count we - do not want to have election triggered on the first failure to - connect - */ - if (++err_count == master_retry_count) + if (++(mi->connects_tried) == mi->retry_count) { slave_was_killed=1; if (reconnect) @@ -7074,6 +7028,7 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi, general_log_print(thd, COM_CONNECT_OUT, "%s@%s:%d", mi->user, mi->host, mi->port); } + ++(mi->connects_tried); // count the final success in addition to failures #ifdef SIGNAL_WITH_VIO_CLOSE thd->set_active_vio(mysql->net.vio); #endif @@ -7089,7 +7044,7 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi, IMPLEMENTATION Try to connect until successful or slave killed or we have retried - master_retry_count times + mi->retry_count times */ static int safe_reconnect(THD* thd, MYSQL* mysql, Master_info* mi, diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 7f4781c1cd5b9..cdc4209faf2de 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -9201,14 +9201,16 @@ int make_proc_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) Constants for columns that are present in SHOW ALL SLAVES STATUS that are not in SHOW SLAVE STATUS. Specifically, columns 0 and 1, and - everything at and above 56. + everything between 56 and 64 inclusive. 0: Connection_name 1: Slave_SQL_State 56: Retried_transactions + 64: Master_Slave_time_diff */ #define SLAVE_STATUS_COL_CONNECTION_NAME 0 #define SLAVE_STATUS_COL_SLAVE_SQL_STATE 1 #define SLAVE_STATUS_COL_RETRIED_TRANSACTIONS 56 +#define SLAVE_STATUS_COL_MASTER_SLAVE_TIME_DIFF 64 static int make_slave_status_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) { @@ -9220,18 +9222,13 @@ static int make_slave_status_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) for (uint i=0; !field_info->end_marker(); field_info++, i++) { if (all_slaves || - // not SLAVE_STATUS_COL_CONNECTION_NAME, - // SLAVE_STATUS_COL_SLAVE_SQL_STATE - // and less - // SLAVE_STATUS_COL_RETRIED_TRANSACTIONS - !(i <= SLAVE_STATUS_COL_SLAVE_SQL_STATE || - i >= SLAVE_STATUS_COL_RETRIED_TRANSACTIONS)) + (i > SLAVE_STATUS_COL_SLAVE_SQL_STATE && + i < SLAVE_STATUS_COL_RETRIED_TRANSACTIONS) || + i > SLAVE_STATUS_COL_MASTER_SLAVE_TIME_DIFF) { LEX_CSTRING field_name= field_info->name(); Item_field *field= new (thd->mem_root) Item_field(thd, context, field_name); - DBUG_ASSERT(all_slaves || (i > SLAVE_STATUS_COL_SLAVE_SQL_STATE && - i < SLAVE_STATUS_COL_RETRIED_TRANSACTIONS)); if (!field || add_item_to_list(thd, field)) return 1; } @@ -10710,6 +10707,8 @@ ST_FIELD_INFO slave_status_info[]= Column("Master_last_event_time", Datetime(0), NULLABLE), Column("Slave_last_event_time", Datetime(0), NULLABLE), Column("Master_Slave_time_diff", SLonglong(10), NULLABLE), + Column("Connects_Tried", ULonglong(20), NOT_NULL), + Column("Primary_Retry_Count", ULonglong(20), NOT_NULL), CEnd() }; diff --git a/storage/perfschema/table_replication_connection_configuration.cc b/storage/perfschema/table_replication_connection_configuration.cc index 8113507475428..71c39b2e98d90 100644 --- a/storage/perfschema/table_replication_connection_configuration.cc +++ b/storage/perfschema/table_replication_connection_configuration.cc @@ -255,7 +255,7 @@ void table_replication_connection_configuration::make_row(Master_info *mi) m_row.connection_retry_interval= (unsigned int) mi->connect_retry; - m_row.connection_retry_count= master_retry_count; //(ulong) mi->retry_count; + m_row.connection_retry_count= mi->retry_count; m_row.heartbeat_interval= (double)mi->heartbeat_period;