| 1 |
--source include/have_innodb.inc |
| 2 |
--source include/master-slave.inc |
| 3 |
|
| 4 |
--connection master |
| 5 |
ALTER TABLE mysql.gtid_slave_pos ENGINE = InnoDB; |
| 6 |
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) Engine=InnoDB; |
| 7 |
--sync_slave_with_master |
| 8 |
|
| 9 |
--connection slave |
| 10 |
--source include/stop_slave.inc |
| 11 |
# Provoke a duplicate key error on replication. |
| 12 |
SET sql_log_bin= 0; |
| 13 |
CALL mtr.add_suppression("Commit failed due to failure of an earlier commit on which this one depends"); |
| 14 |
INSERT INTO t1 VALUES (1, 2); |
| 15 |
SET sql_log_bin= 1; |
| 16 |
--echo Contents on slave before: |
| 17 |
SELECT * FROM t1 ORDER BY a; |
| 18 |
|
| 19 |
SET @old_parallel= @@GLOBAL.slave_parallel_threads; |
| 20 |
SET GLOBAL slave_parallel_threads=8; |
| 21 |
|
| 22 |
--connection master |
| 23 |
|
| 24 |
CREATE TEMPORARY TABLE t2 LIKE t1; |
| 25 |
INSERT INTO t2 VALUE (1, 1); |
| 26 |
INSERT INTO t2 VALUE (2, 1); |
| 27 |
INSERT INTO t2 VALUE (3, 1); |
| 28 |
INSERT INTO t2 VALUE (4, 1); |
| 29 |
INSERT INTO t2 VALUE (5, 1); |
| 30 |
INSERT INTO t1 SELECT * FROM t2; |
| 31 |
DROP TEMPORARY TABLE t2; |
| 32 |
INSERT INTO t1 VALUE (6, 3); |
| 33 |
--source include/save_master_gtid.inc |
| 34 |
--echo Contents on master: |
| 35 |
SELECT * FROM t1 ORDER BY a; |
| 36 |
|
| 37 |
--connection slave |
| 38 |
START SLAVE; |
| 39 |
# The slave will stop with a duplicate key error. |
| 40 |
# The bug was 1) that the next DROP TEMPORARY TABLE would be allowed to run |
| 41 |
# anyway, and 2) that then record_gtid() would get an error during commit |
| 42 |
# (since the prior commit failed), and this error was not correctly handled, |
| 43 |
# which caused an assertion about closing tables while a statement was still |
| 44 |
# active. |
| 45 |
--let $slave_sql_errno=1062 |
| 46 |
--source include/wait_for_slave_sql_error.inc |
| 47 |
|
| 48 |
STOP SLAVE IO_THREAD; |
| 49 |
--echo Contents on slave on slave error: |
| 50 |
SELECT * FROM t1 ORDER BY a; |
| 51 |
|
| 52 |
# Resolve the duplicate key error so replication can be resumed. |
| 53 |
SET sql_log_bin= 0; |
| 54 |
DELETE FROM t1 WHERE a=1; |
| 55 |
SET sql_log_bin= 1; |
| 56 |
|
| 57 |
--source include/start_slave.inc |
| 58 |
--source include/sync_with_master_gtid.inc |
| 59 |
--echo Contents on slave after: |
| 60 |
SELECT * FROM t1 ORDER BY a; |
| 61 |
|
| 62 |
--connection master |
| 63 |
DROP TABLE t1; |
| 64 |
|
| 65 |
--connection slave |
| 66 |
--source include/stop_slave.inc |
| 67 |
SET GLOBAL slave_parallel_threads= @old_parallel; |
| 68 |
--source include/start_slave.inc |
| 69 |
|
| 70 |
--source include/rpl_end.inc |