1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
|
# ==== Purpose ====
#
# This include will verify the update of the relay log info on table
# in a set of situations described at rpl_sync_relay_log_info.test
#
# ==== Usage ====
#
# [--let $storage_engine= InnoDB | MyISAM]
# --source extra/rpl_tests/rpl_sync_relay_log_info.inc
#
# Parameters:
# $storage_engine
# The storage engine that will be used in the CREATE TABLE statement.
# If not specified, InnoDB will be used.
#
if (!$storage_engine)
{
--let $_storage_engine= INNODB
}
if ($storage_engine)
{
--let $_storage_engine= `SELECT UPPER('$storage_engine')`
}
if ( `SELECT '$_storage_engine' <> 'INNODB' AND '$_storage_engine' <> 'MYISAM'` )
{
--die ERROR IN TEST: invalid value for mysqltest variable 'storage_engine': $storage_engine
}
# Sync slave SQL with master
--source include/rpl_connection_master.inc
--source include/sync_slave_sql_with_master.inc
# Define test "header"
--let $_rrli_sync= `SELECT @@GLOBAL.sync_relay_log_info`
--let $_rrli_header= $_storage_engine, sync_rli=$_rrli_sync
# Initialize the sub test counter
--let $_rrli_counter= 0
# 1 - Stop the slave should always sync SQL thread positions
--source include/stop_slave.inc
--let $gtid_step_uuid= $master_uuid
--source include/gtid_step_reset.inc
--let $gtid_step_count= 0
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# Start the slave
--source include/start_slave.inc
# 2 - Simple DDL
--source include/rpl_connection_master.inc
--eval CREATE TABLE t1 (c1 int PRIMARY KEY) ENGINE=$storage_engine
--source include/sync_slave_io_with_master.inc
--let $gtid_step_count= 1
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# 3 - Simple DML
--source include/rpl_connection_master.inc
INSERT INTO t1 VALUES (1);
--source include/sync_slave_io_with_master.inc
--let $gtid_step_count= 1
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# 4 - The master has flushed the binary log
--source include/rpl_connection_master.inc
FLUSH LOCAL BINARY LOGS;
--source include/sync_slave_io_with_master.inc
--let $gtid_step_count= 0
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# 5 - Simple DDL
--source include/rpl_connection_master.inc
DROP TABLE t1;
--source include/sync_slave_io_with_master.inc
--let $gtid_step_count= 1
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# 6 - Stop the slave and restart only the SQL thread
--source include/stop_slave.inc
--source include/start_slave_sql.inc
--let $gtid_step_count= 0
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# 7 - The GTID of a simple DDL
--source include/rpl_connection_master.inc
--eval CREATE TABLE t1 (c1 int PRIMARY KEY) ENGINE=$storage_engine
# Hang the I/O thread after the GTID is received
--source include/rpl_connection_slave.inc
--let $rpl_after_received_events_action= hang
--let $rpl_event_count= 1
--let $rpl_count_only_event_type= Gtid
--let $rpl_continue_event_count_after_hanging= 0
--source include/rpl_receive_event_count.inc
--let $gtid_step_count= 0
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# 8 - Flushed the relay log in the middle of the DDL
FLUSH LOCAL RELAY LOGS;
--let $gtid_step_count= 0
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# 9 - The rest of the simple DDL
SET DEBUG_SYNC= 'now SIGNAL continue_after_queue_event';
--source include/rpl_connection_master.inc
--source include/sync_slave_io_with_master.inc
--let $gtid_step_count= 1
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# 10 - Stop the slave and restart only the SQL thread
--source include/stop_slave.inc
--source include/start_slave_sql.inc
--let $gtid_step_count= 0
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# 11 - The GTID of a simple DML
--source include/rpl_connection_master.inc
INSERT INTO t1 VALUES (2);
# Hang the I/O thread after the GTID is received
--source include/rpl_connection_slave.inc
--let $rpl_after_received_events_action= hang
--let $rpl_event_count= 1
--let $rpl_count_only_event_type= Gtid
--let $rpl_continue_event_count_after_hanging= 0
--source include/rpl_receive_event_count.inc
--let $gtid_step_count= 0
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# 12 - Flushed the relay log in the middle of the DML
FLUSH LOCAL RELAY LOGS;
--let $gtid_step_count= 0
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# 13 - The rest of the simple DML
SET DEBUG_SYNC= 'now SIGNAL continue_after_queue_event';
--source include/rpl_connection_master.inc
--source include/sync_slave_io_with_master.inc
--let $gtid_step_count= 1
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# 14 - Stop the slave and restart only the SQL thread
--source include/stop_slave.inc
--source include/start_slave_sql.inc
--let $gtid_step_count= 0
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# 15 - The GTID of a simple DML with a User var
--source include/rpl_connection_master.inc
SET @v=3;
INSERT INTO t1 VALUES (@v);
# Hang the I/O thread after the User var is received
--source include/rpl_connection_slave.inc
--let $rpl_after_received_events_action= hang
--let $rpl_event_count= 1
--let $rpl_count_only_event_type= User var
--let $rpl_continue_event_count_after_hanging= 0
--source include/rpl_receive_event_count.inc
--let $gtid_step_count= 0
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# 16 - Flushed the relay log in the middle of the DML
FLUSH LOCAL RELAY LOGS;
--let $gtid_step_count= 0
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# 17 - The rest of the simple DML
SET DEBUG_SYNC= 'now SIGNAL continue_after_queue_event';
--source include/rpl_connection_master.inc
--source include/sync_slave_io_with_master.inc
--let $gtid_step_count= 1
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# 18 - Simple DDL
--source include/rpl_connection_master.inc
DROP TABLE t1;
--source include/sync_slave_io_with_master.inc
--let $gtid_step_count= 1
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# The last part is only applicable for transactional tables
if ($_storage_engine == "INNODB")
{
# 19 - Simple DDL
--source include/rpl_connection_master.inc
--eval CREATE TABLE t1 (c1 int PRIMARY KEY) ENGINE=$storage_engine
--source include/sync_slave_io_with_master.inc
--let $gtid_step_count= 1
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# 20 - Stop the slave and restart only the SQL thread
--source include/stop_slave.inc
--source include/start_slave_sql.inc
--let $gtid_step_count= 0
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# 21 - The first half of a multi statement DML
--source include/rpl_connection_master.inc
BEGIN;
INSERT INTO t1 VALUES (1);
SET @v=2;
INSERT INTO t1 VALUES (@v);
COMMIT;
# Hang the I/O thread after the User var is received
--source include/rpl_connection_slave.inc
--let $rpl_after_received_events_action= hang
--let $rpl_event_count= 1
--let $rpl_count_only_event_type= User var
--let $rpl_continue_event_count_after_hanging= 0
--source include/rpl_receive_event_count.inc
# The GTID of the create table must be executed
--let $gtid_step_count= 0
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# 22 - Flushed the relay log in the middle of the DML
FLUSH LOCAL RELAY LOGS;
--let $gtid_step_count= 0
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# Assert that the multi statement DML was not partially committed
--let $assert_text= ($_rrli_subheader) Multi statement DML was not partially committed
--let $assert_cond= [ SELECT COUNT(*) = 0 FROM t1 ]
--source include/assert.inc
# Make SQL thread to fail
INSERT INTO t1 VALUES (2);
# Assert that we executed the above transaction
--let $gtid_step_count= 1
--let $gtid_step_uuid= `SELECT @@GLOBAL.server_uuid`
--source include/gtid_step_assert.inc
# 23 - The multi statement DML should be rolled back
SET DEBUG_SYNC= 'now SIGNAL continue_after_queue_event';
--source include/rpl_connection_master.inc
--source include/sync_slave_io_with_master.inc
# Wait for the SQL thread to stop with error
--let $slave_sql_errno= convert_error(ER_DUP_ENTRY)
--source include/wait_for_slave_sql_error.inc
--let $gtid_step_count= 0
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# Make SQL thread to succeed when retrying the multi statement DML
DELETE FROM t1 WHERE c1 = 2;
# Assert that we executed the above transaction
--let $gtid_step_count= 1
--let $gtid_step_uuid= `SELECT @@GLOBAL.server_uuid`
--source include/gtid_step_assert.inc
# 24 - The multi statement DML should be rolled back
--source include/start_slave_sql.inc
--source include/rpl_connection_master.inc
--source include/sync_slave_io_with_master.inc
--let $gtid_step_count= 1
--let $gtid_step_uuid= $master_uuid
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
# 25 - Simple DDL
--source include/rpl_connection_master.inc
DROP TABLE t1;
--source include/sync_slave_io_with_master.inc
--let $gtid_step_count= 1
--source extra/rpl_tests/rpl_sync_relay_log_info_assert_pos.inc
}
|