MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:He Zhenxing Date:November 13 2009 3:34am
Subject:Re: bzr commit into mysql-5.1-bugteam branch (Li-Bing.Song:3197)
Bug#48350
View as plain text  
Hi Libing,

Nice work! Patch approved!

See some minor comments below.

Li-Bing.Song@stripped wrote:
> #At file:///home/anders/work/bzrwork/worktree2/mysql-5.1-bugteam/ based on
> revid:anurag.shekhar@stripped
> 
>  3197 Li-Bing.Song@stripped	2009-11-12
>       Bug #48350  	truncate temporary table crashes replication
>       
>       All statements operating on temporary tables should not be binlogged if
> masters
>       are in row-based mode. However, 'TRUNCATE ...' statement for a temporary table
> 
>       is still binlogged if a master is in row-based mode. When the log event is
> executed
>       on slave, it can not found the table being truncated. So it reports an error
> and 
>       aborts.
>       
>       After this patch, 'TRUNCATE ...' statement for a temporary table will not be
>       binlogged, if masters are in row-based mode.
> 
>     added:
>       mysql-test/suite/rpl/r/rpl_trunc_temp_row.result
>       mysql-test/suite/rpl/t/rpl_trunc_temp_row.test

Usually we use rpl_row/stm/mixed prefixes for tests only run with
specific binlog format, so please follow the convention and name this
as: rpl_row_trunc_temp.test

>     modified:
>       sql/sql_delete.cc
> === added file 'mysql-test/suite/rpl/r/rpl_trunc_temp_row.result'
> --- a/mysql-test/suite/rpl/r/rpl_trunc_temp_row.result	1970-01-01 00:00:00 +0000
> +++ b/mysql-test/suite/rpl/r/rpl_trunc_temp_row.result	2009-11-12 08:25:25 +0000
> @@ -0,0 +1,29 @@
> +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;
> +CREATE TEMPORARY TABLE t1(c1 INTEGER);
> +CREATE TABLE t2(c1 INTEGER);
> +CREATE TABLE t1(c1 INTEGER);
> +INSERT INTO t1 VALUES(1), (2);
> +INSERT INTO t2 VALUES(1), (2);
> +SELECT * FROM t1;
> +c1
> +1
> +2
> +SELECT * FROM t2;
> +c1
> +1
> +2
> +TRUNCATE t1;
> +TRUNCATE t2;
> +SELECT * FROM t1;
> +c1
> +1
> +2
> +SELECT * FROM t2;
> +c1
> +DROP TABLE t1;
> +DROP TABLE t2;
> 
> === added file 'mysql-test/suite/rpl/t/rpl_trunc_temp_row.test'
> --- a/mysql-test/suite/rpl/t/rpl_trunc_temp_row.test	1970-01-01 00:00:00 +0000
> +++ b/mysql-test/suite/rpl/t/rpl_trunc_temp_row.test	2009-11-12 08:25:25 +0000
> @@ -0,0 +1,35 @@
> +#
> +# Bug#48350 truncate temporary table crashes replication 
> +#
> +# All statements operating on temporary tables should not be binlogged in RBR.
> +# However, 'TRUNCATE ...' statement for a temporary table still binlogged in
> +# RBR.
> +#

...However, before fix of bug#48350, 'TRANCATE ...' statement on a
temporary table was binlogged in RBR.

> +
> +--source include/master-slave.inc
> +--source include/have_binlog_format_row.inc
> +
> +#This statement is not binlogged in RBR.
> +CREATE TEMPORARY TABLE t1(c1 INTEGER);
> +CREATE TABLE t2(c1 INTEGER);
> +sync_slave_with_master;
> +
> +CREATE TABLE t1(c1 INTEGER);
> +INSERT INTO t1 VALUES(1), (2);
> +INSERT INTO t2 VALUES(1), (2);
> +SELECT * FROM t1;
> +SELECT * FROM t2;
> +
> +connection master;
> +TRUNCATE t1;
> +TRUNCATE t2;
> +sync_slave_with_master;
> +# t1 will have nothing, if 'TRUNCATE t1' has been replicate from master to
> +# slave.
> +SELECT * FROM t1;
> +SELECT * FROM t2;
> +
> +DROP TABLE t1;
> +connection master;
> +DROP TABLE t2;
> +--source include/master-slave-end.inc
> 
> === modified file 'sql/sql_delete.cc'
> --- a/sql/sql_delete.cc	2009-10-16 10:29:42 +0000
> +++ b/sql/sql_delete.cc	2009-11-12 08:25:25 +0000
> @@ -1089,6 +1089,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST
>    TABLE *table;
>    bool error;
>    uint path_length;
> +  bool is_temporary_table= false;
>    DBUG_ENTER("mysql_truncate");
>  
>    bzero((char*) &create_info,sizeof(create_info));
> @@ -1099,6 +1100,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST
>    /* If it is a temporary table, close and regenerate it */
>    if (!dont_send_ok && (table= find_temporary_table(thd, table_list)))
>    {
> +    is_temporary_table= true;
>      handlerton *table_type= table->s->db_type();
>      TABLE_SHARE *share= table->s;
>      if (!ha_check_storage_engine_flag(table_type, HTON_CAN_RECREATE))
> @@ -1162,11 +1164,9 @@ end:
>    {
>      if (!error)
>      {
> -      /*
> -        TRUNCATE must always be statement-based binlogged (not row-based) so
> -        we don't test current_stmt_binlog_row_based.
> -      */
> -      write_bin_log(thd, TRUE, thd->query(), thd->query_length());
> +      /* In RBR, the statement is not binlogged if the table is temporary. */
> +      if (!is_temporary_table || !thd->current_stmt_binlog_row_based)
> +        write_bin_log(thd, TRUE, thd->query(), thd->query_length());
>        my_ok(thd);		// This should return record count
>      }
>      VOID(pthread_mutex_lock(&LOCK_open));
> 


Thread
bzr commit into mysql-5.1-bugteam branch (Li-Bing.Song:3197) Bug#48350Li-Bing.Song12 Nov
  • Re: bzr commit into mysql-5.1-bugteam branch (Li-Bing.Song:3197)Bug#48350Luís Soares12 Nov
  • Re: bzr commit into mysql-5.1-bugteam branch (Li-Bing.Song:3197)Bug#48350He Zhenxing13 Nov