List:Commits« Previous MessageNext Message »
From:Leonard Zhou Date:February 18 2009 8:51am
Subject:bzr commit into mysql-5.1-bugteam branch (zhou.li:2793) Bug#40013
View as plain text  
#At file:///home/zhl/mysql/rep/5.1/bug40013/

 2793 Leonard Zhou	2009-02-18
      Bug#40013 mixed replication: row based format could lead to stale tmp tables on the slave
      
      In mixed mode, if we create a temporary table and do some update which switch to ROW format, 
      the format will keep in ROW format. 
      So when the session is end, temp table can't be dropped because at cleanup time we
      checks only current binlog format and so skip insertion of DROP TABLE instructions into binlog.
      
      Our solution is that when closing temp tables at cleanup time 
      we write DROP TABLE into binlog if current binlog format is ROW but in MIX mode. 
added:
  mysql-test/suite/rpl/r/rpl_temp_table_mix_row.result
  mysql-test/suite/rpl/t/rpl_temp_table_mix_row.test
modified:
  sql/sql_base.cc

per-file messages:
  mysql-test/suite/rpl/r/rpl_temp_table_mix_row.result
    Test result file.
  mysql-test/suite/rpl/t/rpl_temp_table_mix_row.test
    Test file.
  sql/sql_base.cc
    Didn't do binloging when both current format and default format are ROW.
=== added file 'mysql-test/suite/rpl/r/rpl_temp_table_mix_row.result'
--- a/mysql-test/suite/rpl/r/rpl_temp_table_mix_row.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_temp_table_mix_row.result	2009-02-18 08:50:14 +0000
@@ -0,0 +1,26 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+==== Initialize ====
+[on master]
+CREATE TABLE t1 (a CHAR(48));
+CREATE TEMPORARY TABLE t1_tmp1(a INT);
+INSERT INTO t1 VALUES (UUID());
+[on slave]
+==== Verify results on slave ====
+SHOW STATUS LIKE "Slave_open_temp_tables";
+Variable_name	Value
+Slave_open_temp_tables	1
+[on master]
+[on slave]
+==== Verify results on slave ====
+SHOW STATUS LIKE "Slave_open_temp_tables";
+Variable_name	Value
+Slave_open_temp_tables	0
+==== Clean up ====
+[on master]
+DROP TABLE t1;
+[on slave]

=== added file 'mysql-test/suite/rpl/t/rpl_temp_table_mix_row.test'
--- a/mysql-test/suite/rpl/t/rpl_temp_table_mix_row.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_temp_table_mix_row.test	2009-02-18 08:50:14 +0000
@@ -0,0 +1,49 @@
+# ==== Purpose ====
+#
+# Test that temporary tables are correctly replicated after switching to ROW format in MIX mode.
+# This test case will test the condition of the bug#40013.
+# The test step is:
+#   1: create temp table on connection 'master';
+#   2: switch to ROW format using 'INSERT INTO t1 VALUES (UUID());'
+#   3: disconnect 'master' and connect to a new connection 'master1';
+#   4: sync to slave and check the number of temp tables on slave.
+#
+
+source include/master-slave.inc;
+source include/have_binlog_format_mixed.inc;
+
+--echo ==== Initialize ====
+
+--echo [on master]
+--connection master
+
+CREATE TABLE t1 (a CHAR(48));
+CREATE TEMPORARY TABLE t1_tmp1(a INT);
+INSERT INTO t1 VALUES (UUID());
+
+--echo [on slave]
+sync_slave_with_master;
+
+--echo ==== Verify results on slave ====
+SHOW STATUS LIKE "Slave_open_temp_tables";
+
+--echo [on master]
+--connection master
+
+disconnect master;
+--connection master1
+
+--echo [on slave]
+sync_slave_with_master;
+
+--echo ==== Verify results on slave ====
+SHOW STATUS LIKE "Slave_open_temp_tables";
+
+--echo ==== Clean up ====
+
+--echo [on master]
+--connection master1
+DROP TABLE t1;
+
+--echo [on slave]
+sync_slave_with_master;

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2009-01-07 12:11:37 +0000
+++ b/sql/sql_base.cc	2009-02-18 08:50:14 +0000
@@ -1440,7 +1440,8 @@ void close_temporary_tables(THD *thd)
   if (!thd->temporary_tables)
     return;
 
-  if (!mysql_bin_log.is_open() || thd->current_stmt_binlog_row_based)
+  if (!mysql_bin_log.is_open() || 
+      (thd->current_stmt_binlog_row_based && thd->variables.binlog_format == BINLOG_FORMAT_ROW))
   {
     TABLE *tmp_next;
     for (table= thd->temporary_tables; table; table= tmp_next)

Thread
bzr commit into mysql-5.1-bugteam branch (zhou.li:2793) Bug#40013Leonard Zhou18 Feb
  • Re: bzr commit into mysql-5.1-bugteam branch (zhou.li:2793) Bug#40013He Zhenxing19 Feb
  • Re: bzr commit into mysql-5.1-bugteam branch (zhou.li:2793) Bug#40013Alfranio Correia19 Feb