1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-8075: DROP TEMPORARY TABLE not marked as ddl, causing optimistic parallel replication to fail

CREATE/DROP TEMPORARY TABLE are not safe to optimistically replicate in
parallel with other transactions, so they need to be marked as "ddl" in the
binlog.

This was already done for stand-alone CREATE/DROP TEMPORARY. But temporary
tables can also be created and dropped inside a BEGIN...END transaction, and
such transactions were not marked as ddl. Nor was the DROP TEMPORARY TABLE
statement emitted implicitly when a client connection is closed.

So this patch adds such ddl mark for the missing cases.

The difference to Kristian's original patch is mainly a fix in
mysql_trans_commit_alter_copy_data() to remember the unsafe_rollback_flags
over the temporary commit.
This commit is contained in:
Kristian Nielsen
2017-05-29 11:35:36 +03:00
committed by Monty
parent da7604a294
commit 228479a28c
15 changed files with 429 additions and 26 deletions

View File

@@ -0,0 +1,97 @@
RESET MASTER;
set time_zone="+02:00";
set timestamp=1579613542;
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
/* GTID */ INSERT INTO t1 VALUES (1,0);
/* GTID */ BEGIN;
/* GTID */ INSERT INTO t1 VALUES (2,0);
/* GTID */ ALTER TABLE t1 ADD c INT;
/* GTID */ INSERT INTO t1 VALUES (3,0,0);
/* GTID */ COMMIT;
/* GTID */ BEGIN;
/* GTID */ UPDATE t1 SET b=1, c=1 WHERE a=2;
/* GTID */ CREATE TEMPORARY TABLE t2 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
/* GTID */ INSERT INTO t2 VALUES (4,10), (5,20);
/* GTID */ INSERT INTO t1 SELECT a, 2, b FROM t2;
/* GTID */ DROP TEMPORARY TABLE t2;
/* GTID */ INSERT INTO t1 VALUES (6, 3, 0);
/* GTID */ COMMIT;
/* GTID */ CREATE TEMPORARY TABLE t3 (a INT PRIMARY KEY) ENGINE=InnoDB;
/* GTID */ BEGIN;
/* GTID */ DELETE FROM t1 WHERE a=5;
/* GTID */ INSERT INTO t3 VALUES (7);
/* GTID */ INSERT INTO t1 SELECT a, 4, 0 FROM t3;
/* GTID */ UPDATE t1 SET c=1 WHERE a=7;
/* GTID */ DROP TEMPORARY TABLE t3;
/* GTID */ COMMIT;
/* GTID */ CREATE TEMPORARY TABLE t4 (a INT PRIMARY KEY) ENGINE=InnoDB;
/* GTID */ BEGIN;
/* GTID */ INSERT INTO t1 VALUES (8, 5, 0);
/* GTID */ ALTER TABLE t4 ADD b INT;
/* GTID */ INSERT INTO t1 VALUES (9, 5, 1);
/* GTID */ COMMIT;
set timestamp=1579613542;
/* GTID */ INSERT INTO t1 VALUES (10, 6, 0);
/* GTID */ BEGIN;
/* GTID */ CREATE TEMPORARY TABLE t5 (a INT PRIMARY KEY) ENGINE=InnoDB;
/* GTID */ INSERT INTO t1 VALUES (11, 7, 0);
/* GTID */ COMMIT;
FLUSH LOGS;
# server id 1 end_log_pos # GTID #-#-# trans
BEGIN
# server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
# server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F
COMMIT/*!*/;
# server id 1 end_log_pos # GTID #-#-# trans
BEGIN
# server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
# server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F
COMMIT/*!*/;
# server id 1 end_log_pos # GTID #-#-# ddl
/* GTID */ ALTER TABLE t1 ADD c INT
# server id 1 end_log_pos # GTID #-#-# trans
BEGIN
# server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
# server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F
COMMIT/*!*/;
# server id 1 end_log_pos # GTID #-#-# trans
BEGIN
# server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
# server id 1 end_log_pos # Update_rows: table id # flags: STMT_END_F
# server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
# server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F
# server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
# server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F
COMMIT/*!*/;
# server id 1 end_log_pos # GTID #-#-# trans
BEGIN
# server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
# server id 1 end_log_pos # Delete_rows: table id # flags: STMT_END_F
# server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
# server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F
# server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
# server id 1 end_log_pos # Update_rows: table id # flags: STMT_END_F
COMMIT/*!*/;
# server id 1 end_log_pos # GTID #-#-# trans
BEGIN
# server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
# server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F
COMMIT/*!*/;
# server id 1 end_log_pos # GTID #-#-# trans
BEGIN
# server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
# server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F
COMMIT/*!*/;
# server id 1 end_log_pos # GTID #-#-# trans
BEGIN
# server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
# server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F
COMMIT/*!*/;
# server id 1 end_log_pos # GTID #-#-# trans
BEGIN
# server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
# server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F
COMMIT/*!*/;
# server id 1 end_log_pos # GTID #-#-# ddl
DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `t5`
DROP TABLE t1;