1
0
mirror of https://github.com/MariaDB/server.git synced 2025-04-20 09:08:00 +03:00
Monty 25b5c63905 MDEV-33856: Alternative Replication Lag Representation via Received/Executed Master Binlog Event Timestamps
This commit adds 3 new status variables to 'show all slaves status':

- Master_last_event_time ; timestamp of the last event read from the
  master by the IO thread.
- Slave_last_event_time ; Master timestamp of the last event committed
  on the slave.
- Master_Slave_time_diff: The difference of the above two timestamps.

All the above variables are NULL until the slave has started and the
slave has read one query event from the master that changes data.

- Added information_schema.slave_status, which allows us to remove:
   - show_master_info(), show_master_info_get_fields(),
     send_show_master_info_data(), show_all_master_info()
   - class Sql_cmd_show_slave_status.
   - Protocol::store(I_List<i_string_pair>* str_list) as it is not
     used anymore.
- Changed old SHOW SLAVE STATUS and SHOW ALL SLAVES STATUS to
  use the SELECT code path, as all other SHOW ... STATUS commands.

Other things:
- Xid_log_time is set to time of commit to allow slave that reads the
  binary log to calculate Master_last_event_time and
  Slave_last_event_time.
  This is needed as there is not 'exec_time' for row events.
- Fixed that Load_log_event calculates exec_time identically to
  Query_event.
- Updated RESET SLAVE to reset Master/Slave_last_event_time
- Updated SQL thread's update on first transaction read-in to
  only update Slave_last_event_time on group events.
- Fixed possible (unlikely) bugs in sql_show.cc ...old_format() functions
  if allocation of 'field' would fail.

Reviewed By:
Brandon Nesterenko <brandon.nesterenko@mariadb.com>
Kristian Nielsen <knielsen@knielsen-hq.org>
2024-07-25 08:57:27 -06:00

549 lines
13 KiB
Plaintext

connect slave,127.0.0.1,root,,,$SERVER_MYPORT_3;
connect master1,127.0.0.1,root,,,$SERVER_MYPORT_1;
connect master2,127.0.0.1,root,,,$SERVER_MYPORT_2;
connection slave;
change master 'slave1' to master_port=MYPORT_1, master_host='127.0.0.1', master_user='root', master_ssl_verify_server_cert=0;
change master 'slave2' to master_port=MYPORT_2, master_host='127.0.0.1', master_user='root', master_ssl_verify_server_cert=0;
start slave 'slave1';
set default_master_connection = 'slave1';
include/wait_for_slave_to_start.inc
set default_master_connection = 'slave2';
start all slaves;
Warnings:
Note 1937 SLAVE 'slave2' started
include/wait_for_slave_to_start.inc
set default_master_connection = '';
connection master1;
connection slave;
connection master2;
connection slave;
show all slaves status;
Connection_name slave1
Slave_SQL_State Slave has read all relay log; waiting for more updates
Slave_IO_State Waiting for master to send event
Master_Host 127.0.0.1
Master_User root
Master_Port MYPORT_1
Connect_Retry 60
Master_Log_File master-bin.000001
Read_Master_Log_Pos <read_master_log_pos>
Relay_Log_File mysqld-relay-bin-slave1.000002
Relay_Log_Pos <relay_log_pos>
Relay_Master_Log_File master-bin.000001
Slave_IO_Running Yes
Slave_SQL_Running Yes
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 <read_master_log_pos>
Relay_Log_Space <relay_log_space1>
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 0
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 has read all relay log; waiting for more updates
Slave_DDL_Groups 0
Slave_Non_Transactional_Groups 0
Slave_Transactional_Groups 0
Replicate_Rewrite_DB
Retried_transactions 0
Max_relay_log_size 1073741824
Executed_log_entries 7
Slave_received_heartbeats 0
Slave_heartbeat_period 60.000
Gtid_Slave_Pos
Master_last_event_time NULL
Slave_last_event_time NULL
Master_Slave_time_diff NULL
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
Master_Host 127.0.0.1
Master_User root
Master_Port MYPORT_2
Connect_Retry 60
Master_Log_File master-bin.000001
Read_Master_Log_Pos <read_master_log_pos>
Relay_Log_File mysqld-relay-bin-slave2.000002
Relay_Log_Pos <relay_log_pos>
Relay_Master_Log_File master-bin.000001
Slave_IO_Running Yes
Slave_SQL_Running Yes
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 <read_master_log_pos>
Relay_Log_Space <relay_log_space1>
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 0
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 2
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 has read all relay log; waiting for more updates
Slave_DDL_Groups 0
Slave_Non_Transactional_Groups 0
Slave_Transactional_Groups 0
Replicate_Rewrite_DB
Retried_transactions 0
Max_relay_log_size 1073741824
Executed_log_entries 7
Slave_received_heartbeats 0
Slave_heartbeat_period 60.000
Gtid_Slave_Pos
Master_last_event_time NULL
Slave_last_event_time NULL
Master_Slave_time_diff NULL
#
# MDEV:16437: merge 5.7 P_S replication instrumentation and tables
#
select * from performance_schema.replication_connection_configuration;
CHANNEL_NAME slave2
HOST 127.0.0.1
PORT #
USER root
USING_GTID SLAVE_POS
SSL_ALLOWED YES
SSL_CA_FILE
SSL_CA_PATH
SSL_CERTIFICATE
SSL_CIPHER
SSL_KEY
SSL_VERIFY_SERVER_CERTIFICATE NO
SSL_CRL_FILE
SSL_CRL_PATH
CONNECTION_RETRY_INTERVAL 60
CONNECTION_RETRY_COUNT 100000
HEARTBEAT_INTERVAL 60.000
IGNORE_SERVER_IDS
REPL_DO_DOMAIN_IDS
REPL_IGNORE_DOMAIN_IDS
CHANNEL_NAME slave1
HOST 127.0.0.1
PORT #
USER root
USING_GTID SLAVE_POS
SSL_ALLOWED YES
SSL_CA_FILE
SSL_CA_PATH
SSL_CERTIFICATE
SSL_CIPHER
SSL_KEY
SSL_VERIFY_SERVER_CERTIFICATE NO
SSL_CRL_FILE
SSL_CRL_PATH
CONNECTION_RETRY_INTERVAL 60
CONNECTION_RETRY_COUNT 100000
HEARTBEAT_INTERVAL 60.000
IGNORE_SERVER_IDS
REPL_DO_DOMAIN_IDS
REPL_IGNORE_DOMAIN_IDS
start all slaves;
#
# MDEV:16437: merge 5.7 P_S replication instrumentation and tables
#
select * from performance_schema.replication_applier_status_by_coordinator;
CHANNEL_NAME slave2
THREAD_ID #
SERVICE_STATE ON
LAST_ERROR_NUMBER 0
LAST_ERROR_MESSAGE
LAST_ERROR_TIMESTAMP 0000-00-00 00:00:00
LAST_SEEN_TRANSACTION
LAST_TRANS_RETRY_COUNT 0
CHANNEL_NAME slave1
THREAD_ID #
SERVICE_STATE ON
LAST_ERROR_NUMBER 0
LAST_ERROR_MESSAGE
LAST_ERROR_TIMESTAMP 0000-00-00 00:00:00
LAST_SEEN_TRANSACTION
LAST_TRANS_RETRY_COUNT 0
stop slave 'slave1';
show slave 'slave1' status;
Slave_IO_State
Master_Host 127.0.0.1
Master_User root
Master_Port MYPORT_1
Connect_Retry 60
Master_Log_File master-bin.000001
Read_Master_Log_Pos <read_master_log_pos>
Relay_Log_File mysqld-relay-bin-slave1.000002
Relay_Log_Pos <relay_log_pos>
Relay_Master_Log_File master-bin.000001
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 <read_master_log_pos>
Relay_Log_Space <relay_log_space1>
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
reset slave 'slave1';
show all slaves status;
Connection_name slave1
Slave_SQL_State
Slave_IO_State
Master_Host 127.0.0.1
Master_User root
Master_Port MYPORT_1
Connect_Retry 60
Master_Log_File
Read_Master_Log_Pos 4
Relay_Log_File
Relay_Log_Pos <relay_log_pos>
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 <relay_log_space1>
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
Retried_transactions 0
Max_relay_log_size 1073741824
Executed_log_entries 7
Slave_received_heartbeats 0
Slave_heartbeat_period 60.000
Gtid_Slave_Pos
Master_last_event_time NULL
Slave_last_event_time NULL
Master_Slave_time_diff NULL
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
Master_Host 127.0.0.1
Master_User root
Master_Port MYPORT_2
Connect_Retry 60
Master_Log_File master-bin.000001
Read_Master_Log_Pos <read_master_log_pos>
Relay_Log_File mysqld-relay-bin-slave2.000002
Relay_Log_Pos <relay_log_pos>
Relay_Master_Log_File master-bin.000001
Slave_IO_Running Yes
Slave_SQL_Running Yes
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 <read_master_log_pos>
Relay_Log_Space <relay_log_space1>
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 0
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 2
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 has read all relay log; waiting for more updates
Slave_DDL_Groups 0
Slave_Non_Transactional_Groups 0
Slave_Transactional_Groups 0
Replicate_Rewrite_DB
Retried_transactions 0
Max_relay_log_size 1073741824
Executed_log_entries 7
Slave_received_heartbeats 0
Slave_heartbeat_period 60.000
Gtid_Slave_Pos
Master_last_event_time NULL
Slave_last_event_time NULL
Master_Slave_time_diff NULL
reset slave 'slave1' all;
show all slaves status;
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
Master_Host 127.0.0.1
Master_User root
Master_Port MYPORT_2
Connect_Retry 60
Master_Log_File master-bin.000001
Read_Master_Log_Pos <read_master_log_pos>
Relay_Log_File mysqld-relay-bin-slave2.000002
Relay_Log_Pos <relay_log_pos>
Relay_Master_Log_File master-bin.000001
Slave_IO_Running Yes
Slave_SQL_Running Yes
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 <read_master_log_pos>
Relay_Log_Space <relay_log_space1>
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 0
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 2
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 has read all relay log; waiting for more updates
Slave_DDL_Groups 0
Slave_Non_Transactional_Groups 0
Slave_Transactional_Groups 0
Replicate_Rewrite_DB
Retried_transactions 0
Max_relay_log_size 1073741824
Executed_log_entries 7
Slave_received_heartbeats 0
Slave_heartbeat_period 60.000
Gtid_Slave_Pos
Master_last_event_time NULL
Slave_last_event_time NULL
Master_Slave_time_diff NULL
stop all slaves;
Warnings:
Note 1938 SLAVE 'slave2' stopped
show all slaves status;
Connection_name slave2
Slave_SQL_State
Slave_IO_State
Master_Host 127.0.0.1
Master_User root
Master_Port MYPORT_2
Connect_Retry 60
Master_Log_File master-bin.000001
Read_Master_Log_Pos <read_master_log_pos>
Relay_Log_File mysqld-relay-bin-slave2.000002
Relay_Log_Pos <relay_log_pos>
Relay_Master_Log_File master-bin.000001
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 <read_master_log_pos>
Relay_Log_Space <relay_log_space1>
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 2
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
Retried_transactions 0
Max_relay_log_size 1073741824
Executed_log_entries 7
Slave_received_heartbeats 0
Slave_heartbeat_period 60.000
Gtid_Slave_Pos
Master_last_event_time NULL
Slave_last_event_time NULL
Master_Slave_time_diff NULL
stop all slaves;
include/reset_master_slave.inc
disconnect slave;
connection master1;
include/reset_master_slave.inc
disconnect master1;
connection master2;
include/reset_master_slave.inc
disconnect master2;