| 1 |
# === Purpose === |
| 2 |
# |
| 3 |
# The purpose of this test is assess the behaviour of the information on the |
| 4 |
# performance_schema table replication_applier_status_by_worker after the |
| 5 |
# STOP SLAVE command both for a single thread slave and for a multi-threaded |
| 6 |
# slave. |
| 7 |
# |
| 8 |
# === Implementation === |
| 9 |
# |
| 10 |
# We test four scenarios in which we stop and start the slave, changing between |
| 11 |
# STS and MTS or keeping the number of workers. In each scenario, we test is the |
| 12 |
# values after the stop slave and after the start slave are as expected. |
| 13 |
# |
| 14 |
# === References === |
| 15 |
# |
| 16 |
# BUG#28191382 LAST_APPLIED_TRANSACTION* AND APPLYING_TRANSACTION* ARE PRESERVED |
| 17 |
# ON START SLAVE |
| 18 |
|
| 19 |
|
| 20 |
# the test in binlog format agnostic |
| 21 |
--source include/have_binlog_format_row.inc |
| 22 |
--source include/not_rpl_gtid_only.inc |
| 23 |
--source include/master-slave.inc |
| 24 |
|
| 25 |
CREATE TABLE t1 (a INT); |
| 26 |
--source include/sync_slave_sql_with_master.inc |
| 27 |
|
| 28 |
--source include/rpl_connection_slave.inc |
| 29 |
SET @saved_replica_parallel_workers = @@GLOBAL.replica_parallel_workers; |
| 30 |
--source include/stop_slave.inc |
| 31 |
SET @@GLOBAL.replica_parallel_workers = 0; |
| 32 |
--source include/start_slave.inc |
| 33 |
|
| 34 |
# Four scenarios are tested: |
| 35 |
# Scenario 1: |
| 36 |
# - Switch: STS to STS |
| 37 |
# - Expected outcome: the values must be preserved after START SLAVE |
| 38 |
# Scenario 2: |
| 39 |
# - Switch: STS to MTS |
| 40 |
# - Expected outcome: the values must be cleared after START SLAVE |
| 41 |
# Scenario 3: |
| 42 |
# - Switch: MTS to MTS |
| 43 |
# - Expected outcome: the values must be cleared after START SLAVE |
| 44 |
# Scenario 4: |
| 45 |
# - Switch: MTS to STS |
| 46 |
# - Expected outcome: the values must be cleared after START SLAVE |
| 47 |
# |
| 48 |
# In all four scenarios the values must be preserved after STOP SLAVE |
| 49 |
|
| 50 |
--let $ps_table = performance_schema.replication_applier_status_by_worker |
| 51 |
--let $scenario = 1 |
| 52 |
--let $new_replica_parallel_workers = 0 |
| 53 |
|
| 54 |
while ($scenario < 5) |
| 55 |
{ |
| 56 |
if ($scenario == 2) |
| 57 |
{ |
| 58 |
--let $new_replica_parallel_workers = 1 |
| 59 |
} |
| 60 |
if ($scenario == 4) |
| 61 |
{ |
| 62 |
--let $new_replica_parallel_workers = 0 |
| 63 |
} |
| 64 |
|
| 65 |
--source include/rpl_connection_master.inc |
| 66 |
--eval INSERT INTO t1 VALUES ($scenario) |
| 67 |
--source include/sync_slave_sql_with_master.inc |
| 68 |
|
| 69 |
--let $last_applied_trx_1 = query_get_value(SELECT LAST_APPLIED_TRANSACTION FROM $ps_table, LAST_APPLIED_TRANSACTION, 1) |
| 70 |
--let $last_applied_trx_OCT_1 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1) |
| 71 |
--let $last_applied_trx_ICT_1 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1) |
| 72 |
--let $last_applied_trx_start_apply_1 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1) |
| 73 |
--let $last_applied_trx_end_apply_1 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_END_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_END_APPLY_TIMESTAMP, 1) |
| 74 |
|
| 75 |
--source include/stop_slave.inc |
| 76 |
--eval SET @@GLOBAL.replica_parallel_workers = $new_replica_parallel_workers |
| 77 |
|
| 78 |
--let $last_applied_trx_2 = query_get_value(SELECT LAST_APPLIED_TRANSACTION FROM $ps_table, LAST_APPLIED_TRANSACTION, 1) |
| 79 |
--let $last_applied_trx_OCT_2 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1) |
| 80 |
--let $last_applied_trx_ICT_2 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1) |
| 81 |
--let $last_applied_trx_start_apply_2 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1) |
| 82 |
--let $last_applied_trx_end_apply_2 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_END_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_END_APPLY_TIMESTAMP, 1) |
| 83 |
|
| 84 |
--source include/start_slave.inc |
| 85 |
|
| 86 |
--let $last_applied_trx_3 = query_get_value(SELECT LAST_APPLIED_TRANSACTION FROM $ps_table, LAST_APPLIED_TRANSACTION, 1) |
| 87 |
--let $last_applied_trx_OCT_3 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1) |
| 88 |
--let $last_applied_trx_ICT_3 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1) |
| 89 |
--let $last_applied_trx_start_apply_3 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP, 1) |
| 90 |
--let $last_applied_trx_end_apply_3 = query_get_value(SELECT LAST_APPLIED_TRANSACTION_END_APPLY_TIMESTAMP FROM $ps_table, LAST_APPLIED_TRANSACTION_END_APPLY_TIMESTAMP, 1) |
| 91 |
|
| 92 |
--let $assert_cond = "$last_applied_trx_1" = "$last_applied_trx_2" |
| 93 |
--let $assert_text = The GTID information about the last applied transaction was preserved after the slave was stopped |
| 94 |
--source include/assert.inc |
| 95 |
|
| 96 |
--let $assert_cond = "$last_applied_trx_OCT_1" = "$last_applied_trx_OCT_2" |
| 97 |
--let $assert_text = The OCT information about the last applied transaction was preserved after the slave was stopped |
| 98 |
--source include/assert.inc |
| 99 |
|
| 100 |
--let $assert_cond = "$last_applied_trx_ICT_1" = "$last_applied_trx_ICT_2" |
| 101 |
--let $assert_text = The ICT information about the last applied transaction was preserved after the slave was stopped |
| 102 |
--source include/assert.inc |
| 103 |
|
| 104 |
--let $assert_cond = "$last_applied_trx_start_apply_1" = "$last_applied_trx_start_apply_2" |
| 105 |
--let $assert_text = The start apply timestamp information about the last applied transaction was preserved after the slave was stopped |
| 106 |
--source include/assert.inc |
| 107 |
|
| 108 |
--let $assert_cond = "$last_applied_trx_end_apply_1" = "$last_applied_trx_end_apply_2" |
| 109 |
--let $assert_text = The end apply timestamp information about the last applied transaction was preserved after the slave was stopped |
| 110 |
--source include/assert.inc |
| 111 |
|
| 112 |
if ($scenario == 1) |
| 113 |
{ |
| 114 |
--let $assert_cond = "$last_applied_trx_2" = "$last_applied_trx_3" |
| 115 |
--let $assert_text = The GTID information about the last applied transaction was preserved after the slave was started |
| 116 |
} |
| 117 |
if ($scenario != 1) |
| 118 |
{ |
| 119 |
--let $assert_cond = "$last_applied_trx_3" = "" |
| 120 |
--let $assert_text = The GTID information about the last applied transaction was cleared after the slave was started |
| 121 |
} |
| 122 |
--source include/assert.inc |
| 123 |
|
| 124 |
if ($scenario == 1) |
| 125 |
{ |
| 126 |
--let $assert_cond = "$last_applied_trx_OCT_2" = "$last_applied_trx_OCT_3" |
| 127 |
--let $assert_text = The OCT information about the last applied transaction was preserved after the slave was started |
| 128 |
} |
| 129 |
if ($scenario != 1) |
| 130 |
{ |
| 131 |
--let $assert_cond = "$last_applied_trx_OCT_3" = "0000-00-00 00:00:00.000000" |
| 132 |
--let $assert_text = The OCT information about the last applied transaction was cleared after the slave was started |
| 133 |
} |
| 134 |
--source include/assert.inc |
| 135 |
|
| 136 |
if ($scenario == 1) |
| 137 |
{ |
| 138 |
--let $assert_cond = "$last_applied_trx_ICT_2" = "$last_applied_trx_ICT_3" |
| 139 |
--let $assert_text = The ICT information about the last applied transaction was preserved after the slave was started |
| 140 |
} |
| 141 |
if ($scenario != 1) |
| 142 |
{ |
| 143 |
--let $assert_cond = "$last_applied_trx_ICT_3" = "0000-00-00 00:00:00.000000" |
| 144 |
--let $assert_text = The ICT information about the last applied transaction was cleared after the slave was started |
| 145 |
} |
| 146 |
--source include/assert.inc |
| 147 |
|
| 148 |
if ($scenario == 1) |
| 149 |
{ |
| 150 |
--let $assert_cond = "$last_applied_trx_start_apply_2" = "$last_applied_trx_start_apply_3" |
| 151 |
--let $assert_text = The start apply timestamp information about the last applied transaction was preserved after the slave was started |
| 152 |
} |
| 153 |
if ($scenario != 1) |
| 154 |
{ |
| 155 |
--let $assert_cond = "$last_applied_trx_start_apply_3" = "0000-00-00 00:00:00.000000" |
| 156 |
--let $assert_text = The start apply timestamp information about the last applied transaction was cleared after the slave was started |
| 157 |
} |
| 158 |
--source include/assert.inc |
| 159 |
|
| 160 |
if ($scenario == 1) |
| 161 |
{ |
| 162 |
--let $assert_cond = "$last_applied_trx_end_apply_2" = "$last_applied_trx_end_apply_3" |
| 163 |
--let $assert_text = The end apply timestamp information about the last applied transaction was preserved after the slave was started |
| 164 |
} |
| 165 |
if ($scenario != 1) |
| 166 |
{ |
| 167 |
--let $assert_cond = "$last_applied_trx_end_apply_3" = "0000-00-00 00:00:00.000000" |
| 168 |
--let $assert_text = The end apply timestamp information about the last applied transaction was cleared after the slave was started |
| 169 |
} |
| 170 |
--source include/assert.inc |
| 171 |
|
| 172 |
--inc $scenario |
| 173 |
} |
| 174 |
|
| 175 |
# cleanup |
| 176 |
--source include/rpl_connection_master.inc |
| 177 |
DROP TABLE t1; |
| 178 |
--source include/sync_slave_sql_with_master.inc |
| 179 |
--source include/stop_slave.inc |
| 180 |
--disable_warnings |
| 181 |
SET @@GLOBAL.replica_parallel_workers = @saved_replica_parallel_workers; |
| 182 |
--enable_warnings |
| 183 |
--source include/start_slave.inc |
| 184 |
--source include/rpl_end.inc |