| 1 |
# === Purpose === |
| 2 |
# |
| 3 |
# This test checks that the information belonging to a skipped transaction that |
| 4 |
# was previously being retried by the slave will not populate the |
| 5 |
# LAST_APPLIED_TRANSACTION* fields in the performance_schema table |
| 6 |
# replication_applier_status_by_worker. |
| 7 |
# |
| 8 |
# === Implementation === |
| 9 |
# |
| 10 |
# We start by creating a transaction on the slave that will block the |
| 11 |
# transaction replicating from the master. We wait until the transaction from |
| 12 |
# the master reaches the maximum number of retries. Then, we check that the |
| 13 |
# master transaction was not applied in the slave and store the information |
| 14 |
# about the last applied transaction from the performance_schema table |
| 15 |
# replication_applier_status_by_worker. We restart the applier thread so that |
| 16 |
# the master blocked transaction GTID can be skipped and check that the |
| 17 |
# information about the last applied transaction was not changed. |
| 18 |
# |
| 19 |
# === References === |
| 20 |
# |
| 21 |
# WL#9131 Add RETRIES field to replication_applier_status_by_worker P_S table |
| 22 |
# BUG#28177448 SKIPPED TRANSACTION WHICH FAILED EARLIER, POPULATES LAST_APPLIED_TRANSACTION_* |
| 23 |
|
| 24 |
# the table performance_schema.replication_applier_status_by_worker can only |
| 25 |
# have one row for this test to work correctly |
| 26 |
--source include/not_mts_replica_parallel_workers.inc |
| 27 |
# the test is binlog format agnostic |
| 28 |
--source include/have_binlog_format_row.inc |
| 29 |
--source include/master-slave.inc |
| 30 |
--source include/rpl_connection_slave.inc |
| 31 |
CALL mtr.add_suppression(".* Could not execute Write_rows event on table test.*"); |
| 32 |
SET @saved_innodb_lock_wait_timeout = @@GLOBAL.innodb_lock_wait_timeout; |
| 33 |
SET @saved_replica_transaction_retries = @@GLOBAL.replica_transaction_retries; |
| 34 |
SET @@GLOBAL.replica_transaction_retries = 10; |
| 35 |
SET @@GLOBAL.innodb_lock_wait_timeout = 2; |
| 36 |
|
| 37 |
|
| 38 |
--source include/rpl_connection_master.inc |
| 39 |
CREATE TABLE t1 (a INT UNIQUE); |
| 40 |
--source include/sync_slave_sql_with_master.inc |
| 41 |
|
| 42 |
# start a transaction on the slave that locks t1 |
| 43 |
BEGIN; |
| 44 |
INSERT INTO t1 VALUES (1); |
| 45 |
|
| 46 |
# execute a transaction on the master that will be blocked in the slave |
| 47 |
--source include/rpl_connection_master.inc |
| 48 |
SET @@SESSION.GTID_NEXT = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1'; |
| 49 |
INSERT INTO t1 VALUES (1); |
| 50 |
SET @@SESSION.GTID_NEXT = 'AUTOMATIC'; |
| 51 |
|
| 52 |
--source include/rpl_connection_slave.inc |
| 53 |
# wait for replica_transaction_retries to reach the maximum retry value |
| 54 |
--let $slave_sql_errno = convert_error(ER_LOCK_WAIT_TIMEOUT) |
| 55 |
--source include/wait_for_slave_sql_to_stop.inc |
| 56 |
|
| 57 |
--let $assert_cond = [SELECT GTID_SUBSET("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1", @@GLOBAL.GTID_EXECUTED)] = 0 |
| 58 |
--let $assert_text = The master transaction should not be in the slave GTID_EXECUTED set |
| 59 |
--source include/assert.inc |
| 60 |
|
| 61 |
# store the last applied GTID before we restart the applier thread |
| 62 |
--let $ps_table = performance_schema.replication_applier_status_by_worker |
| 63 |
--let $last_applied_trx = query_get_value(SELECT LAST_APPLIED_TRANSACTION FROM $ps_table, LAST_APPLIED_TRANSACTION, 1) |
| 64 |
--let $last_applied_trx_OCT = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1) |
| 65 |
--let $last_applied_trx_ICT = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1) |
| 66 |
--let $last_applied_trx_start_apply = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1) |
| 67 |
--let $last_applied_trx_end_apply = query_get_value(SELECT LAST_APPLIED_TRANSACTION_END_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_END_APPLY_TIMESTAMP, 1) |
| 68 |
--let $last_applied_trx_retries_count = query_get_value(SELECT LAST_APPLIED_TRANSACTION_RETRIES_COUNT FROM $ps_table, LAST_APPLIED_TRANSACTION_RETRIES_COUNT, 1) |
| 69 |
--let $last_applied_trx_errno = query_get_value(SELECT LAST_APPLIED_TRANSACTION_LAST_TRANSIENT_ERROR_NUMBER FROM $ps_table, LAST_APPLIED_TRANSACTION_LAST_TRANSIENT_ERROR_NUMBER, 1) |
| 70 |
--let $last_applied_trx_errmsg = query_get_value(SELECT LAST_APPLIED_TRANSACTION_LAST_TRANSIENT_ERROR_MESSAGE FROM $ps_table, LAST_APPLIED_TRANSACTION_LAST_TRANSIENT_ERROR_MESSAGE, 1) |
| 71 |
--let $last_applied_trx_errts = query_get_value(SELECT LAST_APPLIED_TRANSACTION_LAST_TRANSIENT_ERROR_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_LAST_TRANSIENT_ERROR_TIMESTAMP, 1) |
| 72 |
|
| 73 |
COMMIT; |
| 74 |
# skip the master transaction because the table has already been updated by the |
| 75 |
# slave transaction |
| 76 |
SET @@SESSION.GTID_NEXT = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1'; |
| 77 |
COMMIT; |
| 78 |
SET @@SESSION.GTID_NEXT = 'AUTOMATIC'; |
| 79 |
--source include/start_slave_sql.inc |
| 80 |
|
| 81 |
--source include/rpl_connection_master.inc |
| 82 |
--source include/sync_slave_sql_with_master.inc |
| 83 |
|
| 84 |
--let $assert_cond = [SELECT GTID_SUBSET("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1", @@GLOBAL.GTID_EXECUTED)] = 1 |
| 85 |
--let $assert_text = The master transaction should be in the slave GTID_EXECUTED set |
| 86 |
--source include/assert.inc |
| 87 |
|
| 88 |
--let $new_last_applied_trx = query_get_value(SELECT LAST_APPLIED_TRANSACTION FROM $ps_table, LAST_APPLIED_TRANSACTION, 1) |
| 89 |
--let $new_last_applied_trx_OCT = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1) |
| 90 |
--let $new_last_applied_trx_ICT = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1) |
| 91 |
--let $new_last_applied_trx_start_apply = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1) |
| 92 |
--let $new_last_applied_trx_end_apply = query_get_value(SELECT LAST_APPLIED_TRANSACTION_END_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_END_APPLY_TIMESTAMP, 1) |
| 93 |
--let $new_last_applied_trx_retries_count = query_get_value(SELECT LAST_APPLIED_TRANSACTION_RETRIES_COUNT FROM $ps_table, LAST_APPLIED_TRANSACTION_RETRIES_COUNT, 1) |
| 94 |
--let $new_last_applied_trx_errno = query_get_value(SELECT LAST_APPLIED_TRANSACTION_LAST_TRANSIENT_ERROR_NUMBER FROM $ps_table, LAST_APPLIED_TRANSACTION_LAST_TRANSIENT_ERROR_NUMBER, 1) |
| 95 |
--let $new_last_applied_trx_errmsg = query_get_value(SELECT LAST_APPLIED_TRANSACTION_LAST_TRANSIENT_ERROR_MESSAGE FROM $ps_table, LAST_APPLIED_TRANSACTION_LAST_TRANSIENT_ERROR_MESSAGE, 1) |
| 96 |
--let $new_last_applied_trx_errts = query_get_value(SELECT LAST_APPLIED_TRANSACTION_LAST_TRANSIENT_ERROR_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_LAST_TRANSIENT_ERROR_TIMESTAMP, 1) |
| 97 |
|
| 98 |
--let $assert_cond = "$last_applied_trx" = "$new_last_applied_trx" |
| 99 |
--let $assert_text = The GTID information about the last applied transaction was not changed |
| 100 |
--source include/assert.inc |
| 101 |
|
| 102 |
--let $assert_cond = "$last_applied_trx_OCT" = "$new_last_applied_trx_OCT" |
| 103 |
--let $assert_text = The OCT information about the last applied transaction was not changed |
| 104 |
--source include/assert.inc |
| 105 |
|
| 106 |
--let $assert_cond = "$last_applied_trx_ICT" = "$new_last_applied_trx_ICT" |
| 107 |
--let $assert_text = The ICT information about the last applied transaction was not changed |
| 108 |
--source include/assert.inc |
| 109 |
|
| 110 |
--let $assert_cond = "$last_applied_trx_start_apply" = "$new_last_applied_trx_start_apply" |
| 111 |
--let $assert_text = The start apply timestamp information about the last applied transaction was not changed |
| 112 |
--source include/assert.inc |
| 113 |
|
| 114 |
--let $assert_cond = "$last_applied_trx_end_apply" = "$new_last_applied_trx_end_apply" |
| 115 |
--let $assert_text = The end apply timestamp information about the last applied transaction was not changed |
| 116 |
--source include/assert.inc |
| 117 |
|
| 118 |
--let $assert_cond = "$last_applied_trx_retries_count" = "$new_last_applied_trx_retries_count" |
| 119 |
--let $assert_text = The retries count information about the last applied transaction was not changed |
| 120 |
--source include/assert.inc |
| 121 |
|
| 122 |
--let $assert_cond = "$last_applied_trx_errno" = "$new_last_applied_trx_errno" |
| 123 |
--let $assert_text = The last transient error number information about the last applied transaction was not changed |
| 124 |
--source include/assert.inc |
| 125 |
|
| 126 |
--let $assert_cond = "$last_applied_trx_errmsg" = "$new_last_applied_trx_errmsg" |
| 127 |
--let $assert_text = The last transient error message information about the last applied transaction was not changed |
| 128 |
--source include/assert.inc |
| 129 |
|
| 130 |
--let $assert_cond = "$last_applied_trx_errts" = "$new_last_applied_trx_errts" |
| 131 |
--let $assert_text = The last transient error timestamp information about the last applied transaction was not changed |
| 132 |
--source include/assert.inc |
| 133 |
|
| 134 |
# cleanup |
| 135 |
SET @@GLOBAL.innodb_lock_wait_timeout = @saved_innodb_lock_wait_timeout; |
| 136 |
SET @@GLOBAL.replica_transaction_retries = @saved_replica_transaction_retries; |
| 137 |
--source include/rpl_connection_master.inc |
| 138 |
DROP TABLE t1; |
| 139 |
--source include/sync_slave_sql_with_master.inc |
| 140 |
--source include/rpl_end.inc |