#At file:///home/acorreia/workspace.sun/repository.mysql.new/bzrwork/bug-53421/mysql-trunk-bugfixing/ based on revid:alik@stripped
3086 Alfranio Correia 2010-06-01
BUG#53421 Part of transaction not written in binlog after deadlock, replication
breaks
When a "CREATE TEMPORARY TABLE SELECT * FROM" was executed the OPTION_KEEP_LOG was
not set into the thd->variables.option_bits. For that reason, if the transaction
had updated only transactional engines and was rolled back at the end (.e.g due to
a deadlock) the changes were not written to the binary log, including the creation
of the temporary table.
To fix the problem, we have set the OPTION_KEEP_LOG into the
thd->variables.option_bits when a "CREATE TEMPORARY TABLE
SELECT * FROM" is executed.
modified:
mysql-test/suite/rpl/r/rpl_temp_temporary.result
mysql-test/suite/rpl/t/rpl_temp_temporary.test
sql/sql_parse.cc
=== modified file 'mysql-test/suite/rpl/r/rpl_temp_temporary.result'
--- a/mysql-test/suite/rpl/r/rpl_temp_temporary.result 2010-04-28 12:47:49 +0000
+++ b/mysql-test/suite/rpl/r/rpl_temp_temporary.result 2010-06-01 14:39:07 +0000
@@ -193,8 +193,6 @@ Warnings:
Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it accesses a non-transactional table after accessing a transactional table within the same transaction.
INSERT INTO t_innodb VALUES(1);
COMMIT;
-DROP TABLE t_myisam;
-DROP TABLE t_innodb;
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp1(id int) engine= MyIsam
@@ -214,8 +212,29 @@ master-bin.000001 # Query # # use `test`
master-bin.000001 # Query # # use `test`; INSERT INTO t_innodb VALUES(1)
master-bin.000001 # Query # # use `test`; INSERT INTO t_innodb VALUES(1)
master-bin.000001 # Xid # # COMMIT /* XID */
-master-bin.000001 # Query # # use `test`; DROP TABLE t_myisam
-master-bin.000001 # Query # # use `test`; DROP TABLE t_innodb
+########################################################################
+# VERIFY ITEM 8
+########################################################################
+SET BINLOG_FORMAT=MIXED;
+BEGIN;
+CREATE TEMPORARY TABLE tmp2 SELECT * FROM t_innodb;
+INSERT INTO t_innodb VALUES(1);
+INSERT INTO t_innodb VALUES(1);
+ROLLBACK;
+Warnings:
+Warning 1196 Some non-transactional changed tables couldn't be rolled back
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp2 SELECT * FROM t_innodb
+master-bin.000001 # Query # # use `test`; INSERT INTO t_innodb VALUES(1)
+master-bin.000001 # Query # # use `test`; INSERT INTO t_innodb VALUES(1)
+master-bin.000001 # Query # # ROLLBACK
###################################################################################
# CHECK CONSISTENCY
###################################################################################
+###################################################################################
+# CLEAN UP
+###################################################################################
+DROP TABLE t_myisam;
+DROP TABLE t_innodb;
=== modified file 'mysql-test/suite/rpl/t/rpl_temp_temporary.test'
--- a/mysql-test/suite/rpl/t/rpl_temp_temporary.test 2010-04-28 12:47:49 +0000
+++ b/mysql-test/suite/rpl/t/rpl_temp_temporary.test 2010-06-01 14:39:07 +0000
@@ -34,10 +34,13 @@
# the CREATE TEMPORARY is not logged and the DROP TEMPORARY is extended with
# the IF EXISTS clause.
#
-# 7 - It also verifies if the CONNECTION_ID along with a non-transactional
+# 7 - It verifies if the CONNECTION_ID along with a non-transactional
# table is written outside the transaction boundaries and is not classified
# as unsafe. See BUG#53075.
#
+# 8 - It verifies if OPTION_KEEP_LOG is set and thus forcing to write the
+# trx-cache to the binary log when an rollback is issued and only trx-tables
+# were updated. See BUG#53421.
################################################################################
source include/master-slave.inc;
@@ -186,18 +189,40 @@ INSERT INTO t_innodb VALUES(1);
INSERT INTO t_myisam VALUES(CONNECTION_ID());
INSERT INTO t_innodb VALUES(1);
COMMIT;
-DROP TABLE t_myisam;
-DROP TABLE t_innodb;
+source include/show_binlog_events.inc;
+
+--echo ########################################################################
+--echo # VERIFY ITEM 8
+--echo ########################################################################
+#
+# Before the patch for BUG#53421, nothing were written to the binary log on
+# behalf of the transaction presented below:
+#
+SET BINLOG_FORMAT=MIXED;
+let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
+BEGIN;
+CREATE TEMPORARY TABLE tmp2 SELECT * FROM t_innodb;
+INSERT INTO t_innodb VALUES(1);
+INSERT INTO t_innodb VALUES(1);
+ROLLBACK;
source include/show_binlog_events.inc;
--echo ###################################################################################
--echo # CHECK CONSISTENCY
--echo ###################################################################################
-connection master;
sync_slave_with_master;
+connection master;
--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/test-nmt-master.sql
--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/test-nmt-slave.sql
--diff_files $MYSQLTEST_VARDIR/tmp/test-nmt-master.sql $MYSQLTEST_VARDIR/tmp/test-nmt-slave.sql
+--echo ###################################################################################
+--echo # CLEAN UP
+--echo ###################################################################################
+connection master;
+DROP TABLE t_myisam;
+DROP TABLE t_innodb;
+
+sync_slave_with_master;
=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc 2010-05-28 05:47:58 +0000
+++ b/sql/sql_parse.cc 2010-06-01 14:39:07 +0000
@@ -2670,6 +2670,10 @@ case SQLCOM_PREPARE:
*/
lex->unlink_first_table(&link_to_local);
+ /* So that CREATE TEMPORARY TABLE gets to binlog at commit/rollback */
+ if (create_info.options & HA_LEX_CREATE_TMP_TABLE)
+ thd->variables.option_bits|= OPTION_KEEP_LOG;
+
/*
select_create is currently not re-execution friendly and
needs to be created for every execution of a PS/SP.
Attachment: [text/bzr-bundle]
| Thread |
|---|
| • bzr commit into mysql-trunk-bugfixing branch (alfranio.correia:3086)Bug#53421 | Alfranio Correia | 1 Jun |