| 1 |
# === Purpose === |
| 2 |
# |
| 3 |
# The purpose of this test is to check that after the START SLAVE command, the |
| 4 |
# APPLYING_TRANSACTION* fields in the performance_schema table |
| 5 |
# replication_applier_status_by_worker are cleared. |
| 6 |
# |
| 7 |
# === Implementation === |
| 8 |
# |
| 9 |
# For both STS and MTS configurations, we perform the following operations: |
| 10 |
# - create a transaction on the slave forcing a replicated transaction to reach |
| 11 |
# the maximum replica_transaction_retries |
| 12 |
# - Wait for the slave to reach the error condition ER_LOCK_WAIT_TIMEOUT and |
| 13 |
# rollback the blocking transaction |
| 14 |
# - collect the applying transaction GTID and start_apply timestamp |
| 15 |
# - Start the slave and wait for it to synchronize with the master |
| 16 |
# - collect the last applied transaction GTID and start_apply timestamp |
| 17 |
# - check that the new start start timestamp is more recent than the one |
| 18 |
# collected before the slave was started |
| 19 |
# |
| 20 |
# === References === |
| 21 |
# |
| 22 |
# BUG#28248026 P_S.REPLICATION_APPLIER_STAT_BY_WORKER APPLYING_TRX* INCONSISTENT |
| 23 |
# IN MTS AND STS |
| 24 |
|
| 25 |
# the test is binlog format agnostic |
| 26 |
--source include/have_binlog_format_row.inc |
| 27 |
--source include/only_mts_replica_parallel_type_logical_clock.inc |
| 28 |
--source include/master-slave.inc |
| 29 |
|
| 30 |
--source include/rpl_connection_slave.inc |
| 31 |
call mtr.add_suppression(".*worker thread retried transaction 5 time.*"); |
| 32 |
call mtr.add_suppression(".*The replica coordinator and worker threads are stopped, possibly leaving data in inconsistent state.*"); |
| 33 |
|
| 34 |
SET @saved_replica_parallel_workers= @@GLOBAL.replica_parallel_workers; |
| 35 |
SET @saved_innodb_lock_wait_timeout = @@GLOBAL.innodb_lock_wait_timeout; |
| 36 |
SET @saved_replica_transaction_retries = @@GLOBAL.replica_transaction_retries; |
| 37 |
SET GLOBAL replica_transaction_retries = 5; |
| 38 |
SET GLOBAL innodb_lock_wait_timeout = 2; |
| 39 |
|
| 40 |
--source include/rpl_connection_master.inc |
| 41 |
CREATE TABLE t1 (a INT UNIQUE); |
| 42 |
--source include/sync_slave_sql_with_master.inc |
| 43 |
|
| 44 |
# Scenario 1: single-threaded slave |
| 45 |
# Scenario 2: multi-threaded slave |
| 46 |
--let $ps_table = performance_schema.replication_applier_status_by_worker |
| 47 |
--let $scenario = 1 |
| 48 |
while ($scenario < 3) |
| 49 |
{ |
| 50 |
# start a transaction on the slave that locks t1 |
| 51 |
BEGIN; |
| 52 |
--eval INSERT INTO t1 VALUES ($scenario); |
| 53 |
|
| 54 |
# execute a transaction on the master that will be blocked in the slave |
| 55 |
--source include/rpl_connection_master.inc |
| 56 |
--eval INSERT INTO t1 VALUES ($scenario); |
| 57 |
|
| 58 |
--source include/rpl_connection_slave.inc |
| 59 |
# wait for replica_transaction_retries to reach the maximum retry value |
| 60 |
--let $slave_sql_errno = convert_error(ER_LOCK_WAIT_TIMEOUT) |
| 61 |
--source include/wait_for_slave_sql_to_stop.inc |
| 62 |
|
| 63 |
|
| 64 |
--let $applying_trx_before = query_get_value(SELECT APPLYING_TRANSACTION FROM $ps_table, APPLYING_TRANSACTION, 1) |
| 65 |
--let $applying_trx_start_apply_before = query_get_value(SELECT APPLYING_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, APPLYING_TRANSACTION_START_APPLY_TIMESTAMP, 1) |
| 66 |
|
| 67 |
ROLLBACK; |
| 68 |
|
| 69 |
--source include/start_slave_sql.inc |
| 70 |
--source include/rpl_connection_master.inc |
| 71 |
--source include/sync_slave_sql_with_master.inc |
| 72 |
|
| 73 |
--let $last_applied_trx_after = query_get_value(SELECT LAST_APPLIED_TRANSACTION FROM $ps_table, LAST_APPLIED_TRANSACTION, 1) |
| 74 |
--let $last_applied_trx_start_apply_after = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1) |
| 75 |
|
| 76 |
--let $assert_text = Confirm that we are checking the correct transaction |
| 77 |
--let $assert_cond = "$last_applied_trx_after" = "$applying_trx_before" |
| 78 |
--source include/assert.inc |
| 79 |
|
| 80 |
--let $unix_ts_before= `SELECT UNIX_TIMESTAMP('$applying_trx_start_apply_before')` |
| 81 |
--let $unix_ts_after= `SELECT UNIX_TIMESTAMP('$last_applied_trx_start_apply_after')` |
| 82 |
--let $assert_text = Start apply timestamp must be more recent after start slave to prove that the transaction info was reset |
| 83 |
--let $assert_cond = $unix_ts_after > $unix_ts_before |
| 84 |
--source include/assert.inc |
| 85 |
|
| 86 |
--source include/stop_slave.inc |
| 87 |
SET GLOBAL replica_parallel_workers = 1; |
| 88 |
--source include/start_slave.inc |
| 89 |
--inc $scenario |
| 90 |
} |
| 91 |
|
| 92 |
# cleanup |
| 93 |
--source include/rpl_connection_master.inc |
| 94 |
DROP TABLE t1; |
| 95 |
--source include/sync_slave_sql_with_master.inc |
| 96 |
--source include/stop_slave.inc |
| 97 |
--disable_warnings |
| 98 |
SET GLOBAL replica_parallel_workers = @saved_replica_parallel_workers; |
| 99 |
--enable_warnings |
| 100 |
--source include/start_slave.inc |
| 101 |
SET GLOBAL innodb_lock_wait_timeout = @saved_innodb_lock_wait_timeout; |
| 102 |
SET GLOBAL replica_transaction_retries = @saved_replica_transaction_retries; |
| 103 |
--source include/rpl_end.inc |