| 1 |
--source include/have_innodb.inc |
| 2 |
--source include/have_debug.inc |
| 3 |
--source include/have_debug_sync.inc |
| 4 |
--source include/have_binlog_format_row.inc |
| 5 |
--source include/master-slave.inc |
| 6 |
|
| 7 |
--connection slave |
| 8 |
--source include/stop_slave.inc |
| 9 |
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; |
| 10 |
|
| 11 |
--echo # MDEV-29621 the sequence engine binlog_row_image-full events |
| 12 |
--echo # MDL-deadlock on the parallel slave. |
| 13 |
--connection master |
| 14 |
CREATE SEQUENCE s1; |
| 15 |
SET @@session.binlog_row_image=FULL; |
| 16 |
SET @@session.debug_dbug="+d,binlog_force_commit_id"; |
| 17 |
SET @commit_id=7; |
| 18 |
SET @@gtid_seq_no=100; |
| 19 |
--disable_ps2_protocol |
| 20 |
SELECT NEXT VALUE FOR s1; |
| 21 |
--enable_ps2_protocol |
| 22 |
INSERT INTO s1 VALUES(2, 1, 10, 1, 2, 1, 1, 0); |
| 23 |
SET @@session.debug_dbug=""; |
| 24 |
|
| 25 |
--connection slave |
| 26 |
--let $slave_parallel_threads=`select @@global.slave_parallel_threads` |
| 27 |
--let $slave_parallel_mode=`select @@global.slave_parallel_mode` |
| 28 |
SET @@global.slave_parallel_threads=2; |
| 29 |
SET @@global.slave_parallel_mode=optimistic; |
| 30 |
SET @@global.debug_dbug="+d,hold_worker_on_schedule"; |
| 31 |
--source include/start_slave.inc |
| 32 |
|
| 33 |
--let $wait_condition= SELECT count(*) = 1 FROM information_schema.processlist WHERE state LIKE "Waiting for prior transaction to start commit" |
| 34 |
--source include/wait_condition.inc |
| 35 |
SET DEBUG_SYNC = 'now SIGNAL continue_worker'; |
| 36 |
|
| 37 |
--connection master |
| 38 |
DROP SEQUENCE s1; |
| 39 |
--sync_slave_with_master |
| 40 |
--source include/stop_slave.inc |
| 41 |
|
| 42 |
--echo # Simulate buggy 10.3.36 master to prove the parallel applier |
| 43 |
--echo # does not deadlock now at replaying the above master load. |
| 44 |
--connection master |
| 45 |
--let $datadir= `SELECT @@datadir` |
| 46 |
|
| 47 |
--let $rpl_server_number= 1 |
| 48 |
--source include/rpl_stop_server.inc |
| 49 |
|
| 50 |
--remove_file $datadir/master-bin.000001 |
| 51 |
--copy_file $MYSQL_TEST_DIR/std_data/rpl/master-bin-seq_10.3.36.000001 $datadir/master-bin.000001 |
| 52 |
|
| 53 |
--let $rpl_server_number= 1 |
| 54 |
--source include/rpl_start_server.inc |
| 55 |
|
| 56 |
--source include/wait_until_connected_again.inc |
| 57 |
--save_master_pos |
| 58 |
|
| 59 |
--connection slave |
| 60 |
RESET MASTER; |
| 61 |
SET @@global.gtid_slave_pos=""; |
| 62 |
|
| 63 |
--replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1 |
| 64 |
eval CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_1, master_user='root', master_use_gtid=slave_pos; |
| 65 |
|
| 66 |
START SLAVE UNTIL MASTER_GTID_POS='0-1-102'; |
| 67 |
|
| 68 |
--let $wait_condition= SELECT count(*) = 1 FROM information_schema.processlist WHERE state LIKE "Waiting for prior transaction to commit" |
| 69 |
--source include/wait_condition.inc |
| 70 |
SET DEBUG_SYNC = 'now SIGNAL continue_worker'; |
| 71 |
|
| 72 |
--echo # Normal stop is expected |
| 73 |
--source include/wait_for_slave_to_stop.inc |
| 74 |
|
| 75 |
--echo # MDEV-31077 ALTER SEQUENCE may end up in optimistic parallel slave binlog out-of-order |
| 76 |
--echo # The test proves ALTER-SEQUENCE binlogs first before the following transaction does so. |
| 77 |
|
| 78 |
--connection slave |
| 79 |
--source include/stop_slave.inc |
| 80 |
RESET MASTER; |
| 81 |
SET @@global.gtid_slave_pos=""; |
| 82 |
--connection master |
| 83 |
RESET MASTER; |
| 84 |
|
| 85 |
# Load from master |
| 86 |
CREATE TABLE ti (a INT) ENGINE=innodb; |
| 87 |
CREATE SEQUENCE s2 ENGINE=innodb; |
| 88 |
--source include/save_master_gtid.inc |
| 89 |
|
| 90 |
--connection slave |
| 91 |
--source include/start_slave.inc |
| 92 |
--source include/sync_with_master_gtid.inc |
| 93 |
--source include/stop_slave.inc |
| 94 |
--let $rpl_server_number= 2 |
| 95 |
--source include/rpl_restart_server.inc |
| 96 |
# upon restart |
| 97 |
SET @@global.slave_parallel_threads=2; |
| 98 |
SET @@global.slave_parallel_mode=optimistic; |
| 99 |
SET @@global.debug_dbug="+d,hold_worker_on_schedule"; |
| 100 |
--let $slave_gtid_strict_mode=`select @@global.gtid_strict_mode` |
| 101 |
SET @@global.gtid_strict_mode=1; |
| 102 |
|
| 103 |
--connection master |
| 104 |
SET @@gtid_seq_no=100; |
| 105 |
ALTER SEQUENCE s2 restart with 1; |
| 106 |
INSERT INTO ti SET a=1; |
| 107 |
--source include/save_master_gtid.inc |
| 108 |
SELECT @@global.gtid_binlog_state "Master gtid state"; |
| 109 |
|
| 110 |
--connection slave |
| 111 |
# The following FT complicates the opening table time with committing |
| 112 |
# an internal transaction. The rest of the test also proves |
| 113 |
# MDEV-31503 "branch" of the OOO error is fixed. |
| 114 |
SET STATEMENT sql_log_bin=0 FOR FLUSH TABLES; |
| 115 |
--source include/start_slave.inc |
| 116 |
|
| 117 |
--let $wait_condition= SELECT count(*) = 1 FROM information_schema.processlist WHERE state LIKE "Waiting for prior transaction to commit" |
| 118 |
--source include/wait_condition.inc |
| 119 |
|
| 120 |
SELECT @@global.gtid_binlog_state, @@global.gtid_slave_pos as "no 100,101 yet in both"; |
| 121 |
|
| 122 |
# DEBUG_DBUG extension point of hold_worker_on_schedule is reused |
| 123 |
# (gets deployed) in Sql_cmd_alter_sequence::execute. |
| 124 |
SET DEBUG_SYNC = 'now SIGNAL continue_worker'; |
| 125 |
|
| 126 |
--echo # Normal sync with master proves the fixes correct |
| 127 |
--source include/sync_with_master_gtid.inc |
| 128 |
|
| 129 |
SELECT @@global.gtid_binlog_state, @@global.gtid_slave_pos as "all through 101 have been committed"; |
| 130 |
|
| 131 |
# |
| 132 |
# MDEV-35570 parallel slave ALTER-SEQUNCE attemted to binlog out-of-order. |
| 133 |
# Let two transactions I_1 -> AS_2 where AS_2 depends on a commit parent I_1. |
| 134 |
# Under the bug condition AS_2 may complete its work including binlogging |
| 135 |
# while I_1 is slowly executing Xid_log_event. |
| 136 |
# The test simulate the slowness, AS_2 must defer its completion. |
| 137 |
# |
| 138 |
--connection slave |
| 139 |
--source include/stop_slave.inc |
| 140 |
set @saved_mode= @@global.slave_parallel_mode; |
| 141 |
set @@global.slave_parallel_mode = conservative; |
| 142 |
--source include/start_slave.inc |
| 143 |
|
| 144 |
--connection master |
| 145 |
INSERT INTO ti SET a=2; |
| 146 |
--source include/save_master_gtid.inc |
| 147 |
|
| 148 |
--connection slave |
| 149 |
--source include/sync_with_master_gtid.inc |
| 150 |
# allow to proceed to sync with the 1st following WFPT2SC wait condtion |
| 151 |
lock table ti write; |
| 152 |
# allow to proceed into commit to sync with the 2nd following WFPC wait condition |
| 153 |
--let $saved_dbug= @@GLOBAL.debug_dbug |
| 154 |
SET GLOBAL debug_dbug= "+d,halt_past_mark_start_commit"; |
| 155 |
|
| 156 |
--connection master |
| 157 |
INSERT INTO ti SET a=35570; |
| 158 |
ALTER SEQUENCE s2 restart with 1; |
| 159 |
--source include/save_master_gtid.inc |
| 160 |
|
| 161 |
--connection slave |
| 162 |
--let $wait_condition= SELECT count(*) = 1 FROM information_schema.processlist WHERE state LIKE "Waiting for prior transaction to start commit" |
| 163 |
--source include/wait_condition.inc |
| 164 |
# the 1st wait release |
| 165 |
unlock tables; |
| 166 |
|
| 167 |
--let $wait_condition= SELECT count(*) = 1 FROM information_schema.processlist WHERE state LIKE "Waiting for prior transaction to commit" |
| 168 |
--source include/wait_condition.inc |
| 169 |
# the 2nd wait release |
| 170 |
SET debug_sync = "now SIGNAL past_mark_continue"; |
| 171 |
|
| 172 |
--source include/sync_with_master_gtid.inc |
| 173 |
--source include/stop_slave.inc |
| 174 |
SET @@global.slave_parallel_mode = @saved_mode; |
| 175 |
--eval SET @@global.debug_dbug = $saved_dbug |
| 176 |
--source include/start_slave.inc |
| 177 |
|
| 178 |
# MDEV-31792 Assertion in MDL_context::acquire_lock upon parallel replication of CREATE SEQUENCE |
| 179 |
|
| 180 |
--let $iter = 3 |
| 181 |
while ($iter) |
| 182 |
{ |
| 183 |
--connection slave |
| 184 |
if (`select $iter > 1`) |
| 185 |
{ |
| 186 |
flush tables with read lock; |
| 187 |
} |
| 188 |
if (`select $iter = 1`) |
| 189 |
{ |
| 190 |
BEGIN /* slave local Trx */; |
| 191 |
select count(*) from s3; |
| 192 |
} |
| 193 |
|
| 194 |
--connection master |
| 195 |
CREATE OR REPLACE SEQUENCE s3 ENGINE=innodb; |
| 196 |
# select may return non-deterministically, don't print its result |
| 197 |
--disable_cursor_protocol |
| 198 |
SELECT NEXT VALUE FOR s3 into @tmpvar; |
| 199 |
--enable_cursor_protocol |
| 200 |
--source include/save_master_gtid.inc |
| 201 |
|
| 202 |
--connection slave |
| 203 |
--let $wait_condition= SELECT count(*) = 1 FROM information_schema.processlist WHERE state LIKE "Waiting for prior transaction to start commit%" |
| 204 |
--source include/wait_condition.inc |
| 205 |
|
| 206 |
if (`select $iter > 1`) |
| 207 |
{ |
| 208 |
unlock tables; |
| 209 |
} |
| 210 |
if (`select $iter = 1`) |
| 211 |
{ |
| 212 |
--connection slave |
| 213 |
rollback /* Trx */; |
| 214 |
} |
| 215 |
|
| 216 |
|
| 217 |
--source include/sync_with_master_gtid.inc |
| 218 |
|
| 219 |
--dec $iter |
| 220 |
} |
| 221 |
|
| 222 |
|
| 223 |
# |
| 224 |
# MDEV-29621/MDEV-31077/MDEV-31792 clean up. |
| 225 |
# |
| 226 |
--connection slave |
| 227 |
--source include/stop_slave.inc |
| 228 |
|
| 229 |
SET debug_sync = RESET; |
| 230 |
--eval SET @@global.slave_parallel_threads= $slave_parallel_threads |
| 231 |
--eval SET @@global.slave_parallel_mode= $slave_parallel_mode |
| 232 |
SET @@global.debug_dbug = ""; |
| 233 |
--eval SET @@global.gtid_strict_mode=$slave_gtid_strict_mode |
| 234 |
--source include/start_slave.inc |
| 235 |
|
| 236 |
--connection master |
| 237 |
# MDEV-32593 Assertion failure upon CREATE SEQUENCE |
| 238 |
BEGIN; |
| 239 |
INSERT INTO ti SET a=32593; |
| 240 |
CREATE SEQUENCE s4; |
| 241 |
|
| 242 |
DROP SEQUENCE s2,s3,s4; |
| 243 |
DROP TABLE ti; |
| 244 |
|
| 245 |
--sync_slave_with_master |
| 246 |
|
| 247 |
# MDEV-31779 server crash in Rows_log_event::update_sequence at replaying binlog |
| 248 |
--connection master |
| 249 |
--let $binlog_file = query_get_value(SHOW MASTER STATUS, File, 1) |
| 250 |
--let $binlog_start = query_get_value(SHOW MASTER STATUS, Position, 1) |
| 251 |
CREATE SEQUENCE s; |
| 252 |
--disable_ps2_protocol |
| 253 |
SELECT NEXTVAL(s); |
| 254 |
--enable_ps2_protocol |
| 255 |
flush binary logs; |
| 256 |
DROP SEQUENCE s; |
| 257 |
--exec $MYSQL_BINLOG $datadir/$binlog_file | $MYSQL test |
| 258 |
DROP SEQUENCE s; |
| 259 |
|
| 260 |
--sync_slave_with_master |
| 261 |
|
| 262 |
--connection master |
| 263 |
|
| 264 |
|
| 265 |
--source include/rpl_end.inc |