summaryrefslogtreecommitdiff
path: root/mysql-test/suite
diff options
context:
space:
mode:
authorSujatha <sujatha.sivakumar@mariadb.com>2021-04-08 17:12:59 +0530
committerSujatha <sujatha.sivakumar@mariadb.com>2021-04-08 17:19:51 +0530
commitf9bd7f20124dff1af76a12691b8c337fac6ad3e6 (patch)
tree236775ac67ac6381e51e38b199b9991b930e2ece /mysql-test/suite
parent036ee61246ea4540a10b425363e5379bd592bc1f (diff)
downloadmariadb-git-f9bd7f20124dff1af76a12691b8c337fac6ad3e6.tar.gz
MDEV-20220: Merge 5.7 P_S replication table 'replication_applier_status_by_worker
Step 3: ====== Preserve worker pool information on either STOP SLAVE/Error. In case STOP SLAVE is executed worker threads will be gone, hence worker threads will be unavailable. Querying the table at this stage will give empty rows. To address this case when worker threads are about to stop, due to an error or forced stop, create a backup pool and preserve the data which is relevant to populate performance schema table. Clear the backup pool upon slave start.
Diffstat (limited to 'mysql-test/suite')
-rw-r--r--mysql-test/suite/rpl/r/rpl_parallel_retry.result1
-rw-r--r--mysql-test/suite/rpl/r/rpl_perfschema_applier_status_by_worker.result42
-rw-r--r--mysql-test/suite/rpl/t/rpl_parallel_retry.test6
-rw-r--r--mysql-test/suite/rpl/t/rpl_perfschema_applier_status_by_worker.test96
4 files changed, 145 insertions, 0 deletions
diff --git a/mysql-test/suite/rpl/r/rpl_parallel_retry.result b/mysql-test/suite/rpl/r/rpl_parallel_retry.result
index 29657a13eb7..2cc4044a2cd 100644
--- a/mysql-test/suite/rpl/r/rpl_parallel_retry.result
+++ b/mysql-test/suite/rpl/r/rpl_parallel_retry.result
@@ -127,6 +127,7 @@ include/wait_for_slave_sql_error.inc [errno=1213]
SET GLOBAL debug_dbug=@old_dbug;
retries
10
+include/assert.inc [Performance Schema retries should match with actual retries]
SELECT * FROM t1 ORDER BY a;
a b
1 3
diff --git a/mysql-test/suite/rpl/r/rpl_perfschema_applier_status_by_worker.result b/mysql-test/suite/rpl/r/rpl_perfschema_applier_status_by_worker.result
index 85f7d52dff7..3545dc606ac 100644
--- a/mysql-test/suite/rpl/r/rpl_perfschema_applier_status_by_worker.result
+++ b/mysql-test/suite/rpl/r/rpl_perfschema_applier_status_by_worker.result
@@ -38,6 +38,48 @@ include/wait_for_slave_to_stop.inc
RESET SLAVE ALL;
SET default_master_connection='';
CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='127.0.0.1',MASTER_PORT=$MASTER_MYPORT;
+include/start_slave.inc
+
+# Introduce an error in the worker thread and check for the correctness
+# of error number, message and timestamp fields.
+
+connection master;
+use test;
+create table t(a int primary key);
+connection slave;
+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.]
+Last_Error_Message
+Error 'Table 'test.t' doesn't exist' on query. Default database: 'test'. Query: 'insert into t values(1)'
+
+# Verify that the error fields are preserved after STOP SLAVE.
+
+
+# 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 [So, Service_State after STOP SLAVE should be "OFF".]
+
+# 2. Extract the worker_id and 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.]
+Last_Error_Message
+Error 'Table 'test.t' doesn't exist' on query. Default database: 'test'. Query: 'insert into t values(1)'
+include/stop_slave.inc
+RESET SLAVE;
+connection master;
+DROP TABLE t;
+RESET MASTER;
# Verify that number of rows in 'replication_applier_status_by_worker' table match with
# number of slave_parallel_workers.
diff --git a/mysql-test/suite/rpl/t/rpl_parallel_retry.test b/mysql-test/suite/rpl/t/rpl_parallel_retry.test
index 048c6e1df9b..8ea48a2f176 100644
--- a/mysql-test/suite/rpl/t/rpl_parallel_retry.test
+++ b/mysql-test/suite/rpl/t/rpl_parallel_retry.test
@@ -149,6 +149,12 @@ let $new_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', V
--disable_query_log
eval SELECT $new_retry - $old_retry AS retries;
--enable_query_log
+let $ps_value= query_get_value(select last_trans_retry_count from
+ performance_schema.replication_applier_status_by_worker where
+ last_trans_retry_count > 0, last_trans_retry_count, 1);
+let $assert_text= Performance Schema retries should match with actual retries;
+let $assert_cond= "$ps_value" = $new_retry - $old_retry;
+source include/assert.inc;
SELECT * FROM t1 ORDER BY a;
STOP SLAVE IO_THREAD;
diff --git a/mysql-test/suite/rpl/t/rpl_perfschema_applier_status_by_worker.test b/mysql-test/suite/rpl/t/rpl_perfschema_applier_status_by_worker.test
index b59ab826bcc..6ded461db30 100644
--- a/mysql-test/suite/rpl/t/rpl_perfschema_applier_status_by_worker.test
+++ b/mysql-test/suite/rpl/t/rpl_perfschema_applier_status_by_worker.test
@@ -133,6 +133,102 @@ STOP SLAVE 'slave1';
RESET SLAVE ALL;
SET default_master_connection='';
evalp CHANGE MASTER TO MASTER_USER='root', MASTER_HOST='127.0.0.1',MASTER_PORT=$MASTER_MYPORT;
+--source include/start_slave.inc
+
+--echo
+--echo # Introduce an error in the worker thread and check for the correctness
+--echo # of error number, message and timestamp fields.
+--echo
+
+# Cause an error in Worker thread.
+# 1) Create a table 't' at master, replicate at slave.
+# 2) Drop table 't' at slave only.
+# 3) Insert a value in table 't' on master and replicate on slave.
+# Since slave doesnt have table 't' anymore, worker thread will report an error.
+
+--connection master
+use test;
+create table t(a int primary key);
+sync_slave_with_master;
+drop table t;
+--connection master
+insert into t values(1);
+--connection slave
+let $slave_sql_errno=1146;
+source include/wait_for_slave_sql_error.inc;
+
+--echo
+--echo # Extract the error related fields from SSS and PS table and compare
+--echo # them for correctness.
+--echo
+
+let $sss_value= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1);
+let $ps_value= query_get_value(select Last_Error_Number from performance_schema.replication_applier_status_by_worker, Last_Error_Number, 1);
+let $assert_text= Value returned by SSS and PS table for Last_Error_Number should be same.;
+let $assert_cond= "$sss_value" = "$ps_value";
+source include/assert.inc;
+
+--disable_query_log
+--replace_regex /master-bin.[0-9]+/FILENAME/ /end_log_pos [0-9]+/end_log_pos POSITION/
+select Last_Error_Message from performance_schema.replication_applier_status_by_worker;
+--enable_query_log
+
+--echo
+--echo # Verify that the error fields are preserved after STOP SLAVE.
+--echo
+
+--echo
+--echo # 1. Verify that thread_id changes to NULL and service_state to "off" on
+--echo # STOP SLAVE.
+--echo
+
+let $ps_value= query_get_value(select thread_id from performance_schema.replication_applier_status_by_worker, thread_id, 1);
+let $assert_text= After STOP SLAVE, thread_id should be NULL;
+let $assert_cond= "$ps_value" = "NULL";
+source include/assert.inc;
+
+let $ps_value= query_get_value(select service_state from performance_schema.replication_applier_status_by_worker, service_state, 1);
+let $assert_text= So, Service_State after STOP SLAVE should be "OFF".;
+let $assert_cond= "$ps_value"= "OFF";
+source include/assert.inc;
+
+--echo
+--echo # 2. Extract the worker_id and the error related fields from SSS and PS
+--echo # table and compare them. These fields should preserve their values.
+--echo
+
+let $sss_value= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1);
+let $ps_value= query_get_value(select Last_Error_Number from performance_schema.replication_applier_status_by_worker, Last_Error_Number, 1);
+let $assert_text= Value returned by SSS and PS table for Last_Error_Number should be same.;
+let $assert_cond= "$sss_value" = "$ps_value";
+source include/assert.inc;
+
+--disable_query_log
+--replace_regex /master-bin.[0-9]+/FILENAME/ /end_log_pos [0-9]+/end_log_pos POSITION/
+select Last_Error_Message from performance_schema.replication_applier_status_by_worker;
+--enable_query_log
+
+# The timestamp format is slightly different in SSS and PS.
+# SSS => YYMMDD HH:MM:SS
+# PS => YYYY-MM-DD HH:MM:SS
+# To match the two, we get rid of hyphons from PS output and first two digits
+# the year field so that it can be matched directly.
+
+#--- TODO: Can we include Last_SQL_Error_Timestamp as part of SSS
+
+#let $sss_value= query_get_value(SHOW SLAVE STATUS, Last_SQL_Error_Timestamp, 1);
+#let $ps_value= query_get_value(select Last_Error_Timestamp from performance_schema.replication_applier_status_by_worker, Last_Error_Timestamp, 1);
+#let $ps_value_without_hyphons= `SELECT REPLACE("$ps_value", '-', '')`;
+#let $ps_value_in_sss_format= `select substring("$ps_value_without_hyphons", 3)`;
+#let $assert_text= Value returned by SSS and PS table for Last_Error_Timestamp should be same.;
+#let $assert_cond= "$sss_value" = "$ps_value_in_sss_format";
+#source include/assert.inc;
+
+--source include/stop_slave.inc
+RESET SLAVE;
+--connection master
+DROP TABLE t;
+RESET MASTER;
--echo
--echo # Verify that number of rows in 'replication_applier_status_by_worker' table match with