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/master-slave.inc 23 24CREATE TABLE t1 (a INT); 25--source include/sync_slave_sql_with_master.inc 26 27--source include/rpl_connection_slave.inc 28SET @saved_slave_parallel_workers = @@GLOBAL.slave_parallel_workers; 29--source include/stop_slave.inc 30SET @@GLOBAL.slave_parallel_workers = 0; 31--source include/start_slave.inc 32 33# Four scenarios are tested: 34# Scenario 1: 35# - Switch: STS to STS 36# - Expected outcome: the values must be preserved after START SLAVE 37# Scenario 2: 38# - Switch: STS to MTS 39# - Expected outcome: the values must be cleared after START SLAVE 40# Scenario 3: 41# - Switch: MTS to MTS 42# - Expected outcome: the values must be cleared after START SLAVE 43# Scenario 4: 44# - Switch: MTS to STS 45# - Expected outcome: the values must be cleared after START SLAVE 46# 47# In all four scenarios the values must be preserved after STOP SLAVE 48 49--let $ps_table = performance_schema.replication_applier_status_by_worker 50--let $scenario = 1 51--let $new_slave_parallel_workers = 0 52 53while ($scenario < 5) 54{ 55 if ($scenario == 2) 56 { 57 --let $new_slave_parallel_workers = 1 58 } 59 if ($scenario == 4) 60 { 61 --let $new_slave_parallel_workers = 0 62 } 63 64 --source include/rpl_connection_master.inc 65 --eval INSERT INTO t1 VALUES ($scenario) 66 --source include/sync_slave_sql_with_master.inc 67 68 --let $last_applied_trx_1 = query_get_value(SELECT LAST_APPLIED_TRANSACTION FROM $ps_table, LAST_APPLIED_TRANSACTION, 1) 69 --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) 70 --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) 71 --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) 72 --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) 73 74 --source include/stop_slave.inc 75 --eval SET @@GLOBAL.slave_parallel_workers = $new_slave_parallel_workers 76 77 --let $last_applied_trx_2 = query_get_value(SELECT LAST_APPLIED_TRANSACTION FROM $ps_table, LAST_APPLIED_TRANSACTION, 1) 78 --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) 79 --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) 80 --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) 81 --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) 82 83 --source include/start_slave.inc 84 85 --let $last_applied_trx_3 = query_get_value(SELECT LAST_APPLIED_TRANSACTION FROM $ps_table, LAST_APPLIED_TRANSACTION, 1) 86 --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) 87 --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) 88 --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) 89 --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) 90 91 --let $assert_cond = "$last_applied_trx_1" = "$last_applied_trx_2" 92 --let $assert_text = The GTID information about the last applied transaction was preserved after the slave was stopped 93 --source include/assert.inc 94 95 --let $assert_cond = "$last_applied_trx_OCT_1" = "$last_applied_trx_OCT_2" 96 --let $assert_text = The OCT information about the last applied transaction was preserved after the slave was stopped 97 --source include/assert.inc 98 99 --let $assert_cond = "$last_applied_trx_ICT_1" = "$last_applied_trx_ICT_2" 100 --let $assert_text = The ICT information about the last applied transaction was preserved after the slave was stopped 101 --source include/assert.inc 102 103 --let $assert_cond = "$last_applied_trx_start_apply_1" = "$last_applied_trx_start_apply_2" 104 --let $assert_text = The start apply timestamp information about the last applied transaction was preserved after the slave was stopped 105 --source include/assert.inc 106 107 --let $assert_cond = "$last_applied_trx_end_apply_1" = "$last_applied_trx_end_apply_2" 108 --let $assert_text = The end apply timestamp information about the last applied transaction was preserved after the slave was stopped 109 --source include/assert.inc 110 111 if ($scenario == 1) 112 { 113 --let $assert_cond = "$last_applied_trx_2" = "$last_applied_trx_3" 114 --let $assert_text = The GTID information about the last applied transaction was preserved after the slave was started 115 } 116 if ($scenario != 1) 117 { 118 --let $assert_cond = "$last_applied_trx_3" = "" 119 --let $assert_text = The GTID information about the last applied transaction was cleared after the slave was started 120 } 121 --source include/assert.inc 122 123 if ($scenario == 1) 124 { 125 --let $assert_cond = "$last_applied_trx_OCT_2" = "$last_applied_trx_OCT_3" 126 --let $assert_text = The OCT information about the last applied transaction was preserved after the slave was started 127 } 128 if ($scenario != 1) 129 { 130 --let $assert_cond = "$last_applied_trx_OCT_3" = "0000-00-00 00:00:00.000000" 131 --let $assert_text = The OCT information about the last applied transaction was cleared after the slave was started 132 } 133 --source include/assert.inc 134 135 if ($scenario == 1) 136 { 137 --let $assert_cond = "$last_applied_trx_ICT_2" = "$last_applied_trx_ICT_3" 138 --let $assert_text = The ICT information about the last applied transaction was preserved after the slave was started 139 } 140 if ($scenario != 1) 141 { 142 --let $assert_cond = "$last_applied_trx_ICT_3" = "0000-00-00 00:00:00.000000" 143 --let $assert_text = The ICT information about the last applied transaction was cleared after the slave was started 144 } 145 --source include/assert.inc 146 147 if ($scenario == 1) 148 { 149 --let $assert_cond = "$last_applied_trx_start_apply_2" = "$last_applied_trx_start_apply_3" 150 --let $assert_text = The start apply timestamp information about the last applied transaction was preserved after the slave was started 151 } 152 if ($scenario != 1) 153 { 154 --let $assert_cond = "$last_applied_trx_start_apply_3" = "0000-00-00 00:00:00.000000" 155 --let $assert_text = The start apply timestamp information about the last applied transaction was cleared after the slave was started 156 } 157 --source include/assert.inc 158 159 if ($scenario == 1) 160 { 161 --let $assert_cond = "$last_applied_trx_end_apply_2" = "$last_applied_trx_end_apply_3" 162 --let $assert_text = The end apply timestamp information about the last applied transaction was preserved after the slave was started 163 } 164 if ($scenario != 1) 165 { 166 --let $assert_cond = "$last_applied_trx_end_apply_3" = "0000-00-00 00:00:00.000000" 167 --let $assert_text = The end apply timestamp information about the last applied transaction was cleared after the slave was started 168 } 169 --source include/assert.inc 170 171 --inc $scenario 172} 173 174# cleanup 175--source include/rpl_connection_master.inc 176DROP TABLE t1; 177--source include/sync_slave_sql_with_master.inc 178--source include/stop_slave.inc 179SET @@GLOBAL.slave_parallel_workers = @saved_slave_parallel_workers; 180--source include/start_slave.inc 181--source include/rpl_end.inc 182