| 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_statement.inc |
| 5 |
--let $rpl_topology=1->2 |
| 6 |
--source include/rpl_init.inc |
| 7 |
|
| 8 |
--echo *** Test killing transaction waiting in commit for previous transaction to commit, when not using 2-phase commit *** |
| 9 |
|
| 10 |
--connection server_2 |
| 11 |
SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads; |
| 12 |
--source include/stop_slave.inc |
| 13 |
SET GLOBAL slave_parallel_threads=10; |
| 14 |
CHANGE MASTER TO master_use_gtid=slave_pos; |
| 15 |
--source include/start_slave.inc |
| 16 |
|
| 17 |
--connection server_1 |
| 18 |
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; |
| 19 |
# Use a stored function to inject a debug_sync into the appropriate THD. |
| 20 |
# The function does nothing on the master, and on the slave it injects the |
| 21 |
# desired debug_sync action(s). |
| 22 |
SET sql_log_bin=0; |
| 23 |
--delimiter || |
| 24 |
CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500)) |
| 25 |
RETURNS INT DETERMINISTIC |
| 26 |
BEGIN |
| 27 |
RETURN x; |
| 28 |
END |
| 29 |
|| |
| 30 |
--delimiter ; |
| 31 |
SET sql_log_bin=1; |
| 32 |
CREATE TABLE t3 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; |
| 33 |
--save_master_pos |
| 34 |
|
| 35 |
--connection server_2 |
| 36 |
SET sql_log_bin=0; |
| 37 |
--delimiter || |
| 38 |
CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500)) |
| 39 |
RETURNS INT DETERMINISTIC |
| 40 |
BEGIN |
| 41 |
IF d1 != '' THEN |
| 42 |
SET debug_sync = d1; |
| 43 |
END IF; |
| 44 |
IF d2 != '' THEN |
| 45 |
SET debug_sync = d2; |
| 46 |
END IF; |
| 47 |
RETURN x; |
| 48 |
END |
| 49 |
|| |
| 50 |
--delimiter ; |
| 51 |
SET sql_log_bin=1; |
| 52 |
--sync_with_master |
| 53 |
|
| 54 |
|
| 55 |
# Set up three transactions on the master that will be group-committed |
| 56 |
# together so they can be replicated in parallel on the slave. |
| 57 |
--connect (con_temp3,127.0.0.1,root,,test,$SERVER_MYPORT_1,) |
| 58 |
SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1'; |
| 59 |
SET binlog_format=statement; |
| 60 |
|
| 61 |
SET debug_dbug='+d,row_ins_row_level'; |
| 62 |
send INSERT INTO t3 VALUES (31, foo(31, |
| 63 |
'ha_commit_one_phase WAIT_FOR t2_waiting', |
| 64 |
'commit_one_phase_2 SIGNAL t1_ready WAIT_FOR t1_cont')); |
| 65 |
|
| 66 |
--connection server_1 |
| 67 |
SET debug_sync='now WAIT_FOR master_queued1'; |
| 68 |
|
| 69 |
--connect (con_temp4,127.0.0.1,root,,test,$SERVER_MYPORT_1,) |
| 70 |
SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2'; |
| 71 |
SET binlog_format=statement; |
| 72 |
SET debug_dbug='+d,row_ins_row_level'; |
| 73 |
BEGIN; |
| 74 |
# This insert is just so we can get T2 to wait while a query is running that we |
| 75 |
# can see in SHOW PROCESSLIST so we can get its thread_id to kill later. |
| 76 |
INSERT INTO t3 VALUES (32, foo(32, |
| 77 |
'ha_write_row_end SIGNAL t2_query WAIT_FOR t2_cont', |
| 78 |
'')); |
| 79 |
# This insert sets up debug_sync points so that T2 will tell when it is at its |
| 80 |
# wait point where we want to kill it - and when it has been killed. |
| 81 |
INSERT INTO t3 VALUES (33, foo(33, |
| 82 |
'wait_for_prior_commit_waiting SIGNAL t2_waiting', |
| 83 |
'wait_for_prior_commit_killed SIGNAL t2_killed')); |
| 84 |
send COMMIT; |
| 85 |
|
| 86 |
--connection server_1 |
| 87 |
SET debug_sync='now WAIT_FOR master_queued2'; |
| 88 |
|
| 89 |
--connect (con_temp5,127.0.0.1,root,,test,$SERVER_MYPORT_1,) |
| 90 |
SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued3'; |
| 91 |
SET binlog_format=statement; |
| 92 |
SET debug_dbug='+d,row_ins_row_level'; |
| 93 |
send INSERT INTO t3 VALUES (34, foo(34, |
| 94 |
'', |
| 95 |
'')); |
| 96 |
|
| 97 |
--connection server_1 |
| 98 |
SET debug_sync='now WAIT_FOR master_queued3'; |
| 99 |
SET debug_sync='now SIGNAL master_cont1'; |
| 100 |
|
| 101 |
--connection con_temp3 |
| 102 |
REAP; |
| 103 |
--connection con_temp4 |
| 104 |
REAP; |
| 105 |
--connection con_temp5 |
| 106 |
REAP; |
| 107 |
|
| 108 |
--connection server_1 |
| 109 |
SELECT * FROM t3 WHERE a >= 30 ORDER BY a; |
| 110 |
|
| 111 |
--connection server_2 |
| 112 |
SET sql_log_bin=0; |
| 113 |
CALL mtr.add_suppression("Query execution was interrupted"); |
| 114 |
CALL mtr.add_suppression("Commit failed due to failure of an earlier commit on which this one depends"); |
| 115 |
CALL mtr.add_suppression("Slave: Connection was killed"); |
| 116 |
SET sql_log_bin=1; |
| 117 |
# Wait until T2 is inside executing its insert of 32, then find it in SHOW |
| 118 |
# PROCESSLIST to know its thread id for KILL later. |
| 119 |
SET debug_sync='now WAIT_FOR t2_query'; |
| 120 |
--let $thd_id= `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%foo(32%' AND INFO NOT LIKE '%LIKE%'` |
| 121 |
SET debug_sync='now SIGNAL t2_cont'; |
| 122 |
|
| 123 |
# Wait until T2 has entered its wait for T1 to commit, and T1 has |
| 124 |
# progressed into its commit phase. |
| 125 |
SET debug_sync='now WAIT_FOR t1_ready'; |
| 126 |
|
| 127 |
# Now kill the transaction T2. |
| 128 |
--replace_result $thd_id THD_ID |
| 129 |
eval KILL $thd_id; |
| 130 |
|
| 131 |
# Wait until T2 has reacted on the kill. |
| 132 |
SET debug_sync='now WAIT_FOR t2_killed'; |
| 133 |
|
| 134 |
# Now we can allow T1 to proceed. |
| 135 |
SET debug_sync='now SIGNAL t1_cont'; |
| 136 |
|
| 137 |
--let $slave_sql_errno= 1317,1927,1963 |
| 138 |
--source include/wait_for_slave_sql_error.inc |
| 139 |
STOP SLAVE IO_THREAD; |
| 140 |
SELECT * FROM t3 WHERE a >= 30 ORDER BY a; |
| 141 |
|
| 142 |
# Now we have to disable the debug_sync statements, so they do not trigger |
| 143 |
# when the events are retried. |
| 144 |
SET GLOBAL slave_parallel_threads=0; |
| 145 |
SET GLOBAL slave_parallel_threads=10; |
| 146 |
SET sql_log_bin=0; |
| 147 |
DROP FUNCTION foo; |
| 148 |
--delimiter || |
| 149 |
CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500)) |
| 150 |
RETURNS INT DETERMINISTIC |
| 151 |
BEGIN |
| 152 |
RETURN x; |
| 153 |
END |
| 154 |
|| |
| 155 |
--delimiter ; |
| 156 |
SET sql_log_bin=1; |
| 157 |
|
| 158 |
--connection server_1 |
| 159 |
INSERT INTO t3 VALUES (39,0); |
| 160 |
--save_master_pos |
| 161 |
|
| 162 |
--connection server_2 |
| 163 |
--source include/start_slave.inc |
| 164 |
--sync_with_master |
| 165 |
SELECT * FROM t3 WHERE a >= 30 ORDER BY a; |
| 166 |
# Restore the foo() function. |
| 167 |
SET sql_log_bin=0; |
| 168 |
DROP FUNCTION foo; |
| 169 |
--delimiter || |
| 170 |
CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500)) |
| 171 |
RETURNS INT DETERMINISTIC |
| 172 |
BEGIN |
| 173 |
IF d1 != '' THEN |
| 174 |
SET debug_sync = d1; |
| 175 |
END IF; |
| 176 |
IF d2 != '' THEN |
| 177 |
SET debug_sync = d2; |
| 178 |
END IF; |
| 179 |
RETURN x; |
| 180 |
END |
| 181 |
|| |
| 182 |
--delimiter ; |
| 183 |
SET sql_log_bin=1; |
| 184 |
|
| 185 |
|
| 186 |
--connection server_2 |
| 187 |
# Respawn all worker threads to clear any left-over debug_sync or other stuff. |
| 188 |
--source include/stop_slave.inc |
| 189 |
SET GLOBAL slave_parallel_threads=0; |
| 190 |
SET GLOBAL slave_parallel_threads=10; |
| 191 |
--source include/start_slave.inc |
| 192 |
|
| 193 |
|
| 194 |
--connection server_2 |
| 195 |
--source include/stop_slave.inc |
| 196 |
SET GLOBAL slave_parallel_threads=@old_parallel_threads; |
| 197 |
SET debug_sync = 'reset'; |
| 198 |
--source include/start_slave.inc |
| 199 |
|
| 200 |
--connection server_1 |
| 201 |
DROP function foo; |
| 202 |
DROP TABLE t3; |
| 203 |
SET debug_sync = 'reset'; |
| 204 |
|
| 205 |
--source include/rpl_end.inc |