MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Luís Soares Date:November 12 2009 1:04pm
Subject:Re: bzr commit into mysql-5.1-bugteam branch (Li-Bing.Song:3197)
Bug#48350
View as plain text  
Hi Libing,

  Nice Work. Please find my review comments below.

STATUS
------
  Approved.

REQUIRED CHANGES
----------------
 n/a

REQUESTS
--------
 n/a

SUGGESTIONS
-----------
 n/a

DETAILS 
-------
  One suggestion inline.

On Thu, 2009-11-12 at 08:25 +0000, 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
> 

I am no native speaker, and this is just a suggestion, but to me it
may sound better if we write it like:

All statements operating on temporary tables should not be binlogged if
the master is logging in row-based mode. Despite this fact, after
executing 'TRUNCATE... ' on a temporary table, the command is still
logged, even if in row-based mode. Consequently, this raises
problems in the slave as the table may not exist, resulting in an
execution failure. Ultimately, this causes the slave to report
an error and abort.


>       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
>     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.
> +#
> +
> +--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));
> 
-- 
Luís

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