Skip to content

Commit

Permalink
MDEV-16437: merge 5.7 P_S replication instrumentation and tables
Browse files Browse the repository at this point in the history
Merge 'replication_applier_status_by_coordinator' table.

This table captures SQL_THREAD status in case of both single threaded and
multi threaded slave configuration. When multi_source replication is enabled
this table will display each source specific SQL_THREAD status.

Added new columns for:
 - LAST_SEEN_TRANSACTION
 - LAST_TRANS_RETRY_COUNT
  • Loading branch information
sujatha-s committed Apr 16, 2021
1 parent 2674365 commit 7064287
Show file tree
Hide file tree
Showing 14 changed files with 551 additions and 18 deletions.
20 changes: 20 additions & 0 deletions mysql-test/suite/binlog_encryption/multisource.result
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,26 @@ Last_SQL_Errno = '0'
Slave_heartbeat_period = '60.000'
Slave_heartbeat_period = '60.000'
#
#
# MDEV:16437: merge 5.7 P_S replication instrumentation and tables
#
SELECT * FROM performance_schema.replication_applier_status_by_coordinator;
CHANNEL_NAME master1
THREAD_ID #
SERVICE_STATE ON
LAST_ERROR_NUMBER 0
LAST_ERROR_MESSAGE
LAST_ERROR_TIMESTAMP 0000-00-00 00:00:00
LAST_SEEN_TRANSACTION 0-1-7
LAST_TRANS_RETRY_COUNT 0
CHANNEL_NAME
THREAD_ID #
SERVICE_STATE ON
LAST_ERROR_NUMBER 0
LAST_ERROR_MESSAGE
LAST_ERROR_TIMESTAMP 0000-00-00 00:00:00
LAST_SEEN_TRANSACTION 0-2-4
LAST_TRANS_RETRY_COUNT 0
select * from db1.t1;
i f1
1 one
Expand Down
20 changes: 20 additions & 0 deletions mysql-test/suite/multi_source/multisource.result
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,26 @@ Last_SQL_Errno = '0'
Slave_heartbeat_period = '60.000'
Slave_heartbeat_period = '60.000'
#
#
# MDEV:16437: merge 5.7 P_S replication instrumentation and tables
#
SELECT * FROM performance_schema.replication_applier_status_by_coordinator;
CHANNEL_NAME master1
THREAD_ID #
SERVICE_STATE ON
LAST_ERROR_NUMBER 0
LAST_ERROR_MESSAGE
LAST_ERROR_TIMESTAMP 0000-00-00 00:00:00
LAST_SEEN_TRANSACTION 0-1-7
LAST_TRANS_RETRY_COUNT 0
CHANNEL_NAME
THREAD_ID #
SERVICE_STATE ON
LAST_ERROR_NUMBER 0
LAST_ERROR_MESSAGE
LAST_ERROR_TIMESTAMP 0000-00-00 00:00:00
LAST_SEEN_TRANSACTION 0-2-4
LAST_TRANS_RETRY_COUNT 0
select * from db1.t1;
i f1
1 one
Expand Down
20 changes: 20 additions & 0 deletions mysql-test/suite/multi_source/simple.result
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,26 @@ 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
Expand Down
6 changes: 6 additions & 0 deletions mysql-test/suite/multi_source/simple.test
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ query_vertical select * from performance_schema.replication_connection_configura
# Ensure that start all slaves doesn't do anything as all slaves are started
start all slaves;

--echo #
--echo # MDEV:16437: merge 5.7 P_S replication instrumentation and tables
--echo #
--replace_column 2 #
query_vertical select * from performance_schema.replication_applier_status_by_coordinator;

stop slave 'slave1';

--replace_result $SERVER_MYPORT_1 MYPORT_1 $SERVER_MYPORT_2 MYPORT_2 $read_master_log_pos <read_master_log_pos> $relay_log_pos <relay_log_pos> $relay_log_space1 <relay_log_space1> $relay_log_space2 <relay_log_space2>
Expand Down
4 changes: 3 additions & 1 deletion mysql-test/suite/perfschema/r/table_schema.result
Original file line number Diff line number Diff line change
Expand Up @@ -859,12 +859,14 @@ def performance_schema replication_applier_status CHANNEL_NAME 1 NULL NO char 64
def performance_schema replication_applier_status SERVICE_STATE 2 NULL NO enum 3 9 NULL NULL NULL utf8 utf8_general_ci enum('ON','OFF') select,insert,update,references NEVER NULL
def performance_schema replication_applier_status REMAINING_DELAY 3 NULL YES int NULL NULL 10 0 NULL NULL NULL int(10) unsigned select,insert,update,references NEVER NULL
def performance_schema replication_applier_status COUNT_TRANSACTIONS_RETRIES 4 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references NEVER NULL
def performance_schema replication_applier_status_by_coordinator CHANNEL_NAME 1 NULL NO char 64 192 NULL NULL NULL utf8 utf8_general_ci char(64) select,insert,update,references NEVER NULL
def performance_schema replication_applier_status_by_coordinator CHANNEL_NAME 1 NULL NO varchar 256 768 NULL NULL NULL utf8 utf8_general_ci varchar(256) select,insert,update,references NEVER NULL
def performance_schema replication_applier_status_by_coordinator THREAD_ID 2 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references NEVER NULL
def performance_schema replication_applier_status_by_coordinator SERVICE_STATE 3 NULL NO enum 3 9 NULL NULL NULL utf8 utf8_general_ci enum('ON','OFF') select,insert,update,references NEVER NULL
def performance_schema replication_applier_status_by_coordinator LAST_ERROR_NUMBER 4 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references NEVER NULL
def performance_schema replication_applier_status_by_coordinator LAST_ERROR_MESSAGE 5 NULL NO varchar 1024 3072 NULL NULL NULL utf8 utf8_general_ci varchar(1024) select,insert,update,references NEVER NULL
def performance_schema replication_applier_status_by_coordinator LAST_ERROR_TIMESTAMP 6 current_timestamp() NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update current_timestamp() select,insert,update,references NEVER NULL
def performance_schema replication_applier_status_by_coordinator LAST_SEEN_TRANSACTION 7 NULL NO char 57 171 NULL NULL NULL utf8 utf8_general_ci char(57) select,insert,update,references NEVER NULL
def performance_schema replication_applier_status_by_coordinator LAST_TRANS_RETRY_COUNT 8 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11) select,insert,update,references NEVER NULL
def performance_schema replication_applier_status_by_worker CHANNEL_NAME 1 NULL NO varchar 256 768 NULL NULL NULL utf8 utf8_general_ci varchar(256) select,insert,update,references NEVER NULL
def performance_schema replication_applier_status_by_worker THREAD_ID 2 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references NEVER NULL
def performance_schema replication_applier_status_by_worker SERVICE_STATE 3 NULL NO enum 3 9 NULL NULL NULL utf8 utf8_general_ci enum('ON','OFF') select,insert,update,references NEVER NULL
Expand Down
7 changes: 7 additions & 0 deletions mysql-test/suite/rpl/include/multisource.inc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

--source include/not_embedded.inc
--source include/have_innodb.inc
--source include/have_perfschema.inc
--source include/binlog_start_pos.inc
--let $rpl_server_count= 0

Expand Down Expand Up @@ -263,6 +264,12 @@ let $condition= = 'Waiting for master to send event';
--let $all_slaves_status=
--echo #

--echo #
--echo # MDEV:16437: merge 5.7 P_S replication instrumentation and tables
--echo #
--replace_column 2 #
query_vertical SELECT * FROM performance_schema.replication_applier_status_by_coordinator;

--sorted_result
select * from db1.t1;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
include/master-slave.inc
[connection master]
call mtr.add_suppression("Error 'Table 'test.t' doesn't exist' on query.");
include/assert.inc [On master, the table should return an empty set.]
connection slave;
include/wait_for_slave_param.inc [Slave_SQL_Running_State]

# Testing on fresh slave.

include/assert.inc [thread_name should should indicate sql thread.]
include/assert.inc [SSS shows Slave_IO_Running as "Yes". So, Service_State from this PS table should be "ON".]
include/assert.inc [Value returned by SSS and PS table for Last_Error_Number should be same.]
include/assert.inc [Value returned by SSS and PS table for Last_Error_Message should be same.]
include/assert.inc [Value returned by SSS and PS table for Last_Error_Timestamp should be 0000-00-00 00:00:00.]
include/assert.inc [Last_trans_retry_count should be 0.]

# Cause an error in the SQL thread and check for the correctness of
# values in error number, message and timestamp fields.

connection master;
use test;
create table t(a int primary key);
include/sync_slave_sql_with_master.inc
drop table t;
connection master;
insert into t values(1);
connection slave;
include/wait_for_slave_sql_error.inc [errno=1146]

# Extract the error related fields from SSS and PS table and compare
# them for correctness.

include/assert.inc [Value returned by SSS and PS table for Last_Error_Number should be same.]
Value returned by SSS and PS table for Last_Error_Message is same.

# Verify that the error fields are preserved after STOP SLAVE, thread_id
# changes to NULL and service_state changes to "Off".


# 1. Verify that thread_id changes to NULL and service_state to "off" on
# STOP SLAVE.

include/assert.inc [After STOP SLAVE, thread_id should be NULL]
include/assert.inc [SSS shows Slave_SQL_Running as "No". So, Service_State from this PS table should be "OFF".]

# 2. Extract the error related fields from SSS and PS table and compare
# them. These fields should preserve their values.

include/assert.inc [Value returned by SSS and PS table for Last_Error_Number should be same.]
Value returned by SSS and PS table for Last_Error_Message is same.
connection master;
drop table t;
reset master;
connection slave;
include/stop_slave.inc
reset slave;
reset master;
set @saved_slave_trans_retry_interval= @@GLOBAL.slave_transaction_retry_interval;
set global slave_transaction_retry_interval=1;
include/start_slave.inc
#
# Test Last_Trans_Retry_Count value.
#
connection master;
create table t1 (f int primary key) engine=innodb;
insert into t1 values (10);
connection slave;
connect slave2,127.0.0.1,root,,test,$SLAVE_MYPORT,;
connection slave2;
begin;
update t1 set f=40 where f=10;
connection master;
begin;
update t1 set f=60 where f=10;
commit;
connection slave;
connection slave2;
rollback;
include/assert.inc [Value returned by PS table for Last_Trans_Retry_Count should be > 0.]
connection master;
drop table t1;
connection slave;
disconnect slave2;
set global slave_transaction_retry_interval=@saved_slave_trans_retry_interval;
include/stop_slave.inc

# Restarting servers and setting up MTS now. Since, SQL thread and
# coordinator are the same and follow same code path, we can skip
# testing for coordinator thread in all scenarios. Testing for one
# scenario is enough.

include/rpl_restart_server.inc [server_number=1]
include/rpl_restart_server.inc [server_number=2]
connection slave;
change master to
master_host='127.0.0.1',
master_port=MASTER_MYPORT,
master_user='root';
SET @save.slave_parallel_workers=@@global.slave_parallel_workers;
SET @@global.slave_parallel_workers=1;
set @save.slave_transaction_retries= @@global.slave_transaction_retries;
include/start_slave.inc
include/wait_for_slave_param.inc [Slave_SQL_Running_State]
include/assert.inc [thread_name should should indicate sql thread.]
include/assert.inc [SSS shows Slave_SQL_Running as "Yes". So, Service_State from this PS table should be "ON".]
include/assert.inc [Value returned by SSS and PS table for Last_Error_Number should be same.]

# Cleanup.

include/stop_slave.inc
set @@global.slave_parallel_workers= @save.slave_parallel_workers;
set @@global.slave_transaction_retries= @save.slave_transaction_retries;
include/start_slave.inc
include/rpl_end.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--loose-innodb-lock-wait-timeout=1
Loading

0 comments on commit 7064287

Please sign in to comment.