List:Commits« Previous MessageNext Message »
From:daogang.qu Date:January 19 2011 6:58am
Subject:bzr commit into mysql-trunk branch (daogang.qu:3454) Bug#58784
View as plain text  
#At file:///home/daogang/bzrwork/bug58784/mysql-trunk/ based on revid:marc.alff@stripped

 3454 daogang.qu@stripped	2011-01-19
      Bug #58784  	rpl_row_ignorable_event fails on PB2
      
      In RBR, The rows are inserted to a queue by the thread executing
      the 'INSERT DELAYED' statement, and are taken out from the queue
      by the handler thread to do the real insertion. Because these two
      threads are running in parallel, there is a possibility that they
      are run in an interleaved manner, and result in different number
      of table_map and rows events.
            
      Added 'wait' and 'signal' mechanism for the test to make the
      binlog of multi 'INSERT DELAYED ...' stmt stable by forcing
      every value is executed into one execution series, and then
      each value will be binlogged into a separate rows event with
      its table map event.
     @ mysql-test/suite/rpl/r/rpl_row_ignorable_event.result
        Updated for the patch of bug#58784.
     @ mysql-test/suite/rpl/t/rpl_row_ignorable_event.test
        Added debug option for making the binlog of
        multi 'INSERT DELAYED ...' stmt stable.
     @ sql/sql_insert.cc
        Added 'wait' and 'signal' mechanism to make 'INSERT DELAYED'
        thread wait to insert data into the queue until the signal
        is sent from 'HANDLER' thread, after the last row from the
        queue is taken out and executed.

    modified:
      mysql-test/suite/rpl/r/rpl_row_ignorable_event.result
      mysql-test/suite/rpl/t/rpl_row_ignorable_event.test
      sql/sql_insert.cc
=== modified file 'mysql-test/suite/rpl/r/rpl_row_ignorable_event.result'
--- a/mysql-test/suite/rpl/r/rpl_row_ignorable_event.result	2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_ignorable_event.result	2011-01-19 06:58:42 +0000
@@ -1,7 +1,5 @@
 include/master-slave.inc
 [connection master]
-SET @old_debug= @@global.debug;
-SET GLOBAL debug="+d,waiting_for_delayed_insert_queue_is_empty";
 # Test non-transaction
 create table t1(a int, b int) engine= myisam;
 insert into t1(a,b) values(1,1),(2,1);
@@ -38,6 +36,10 @@ insert into t5(a, b) values(3,1);
 # Test the Rows_query log event will be filtered out if slave filters
 # out all its related tables by replication filtering rules
 update t4,t5 set t4.a=4, t5.a=5 where t4.b=t5.b;
+SET @old_debug= @@global.debug;
+SET GLOBAL debug="+d,after_handle_inserts";
+set DEBUG_SYNC= 'before_write_delayed SIGNAL before_insert EXECUTE 3';
+set DEBUG_SYNC= 'after_write_delayed WAIT_FOR inserts_handled EXECUTE 3';
 # Test insert delayed ...
 insert delayed into t3(a,b) values(1,5),(1,6),(1,7);
 SET @@global.debug= @old_debug;

=== modified file 'mysql-test/suite/rpl/t/rpl_row_ignorable_event.test'
--- a/mysql-test/suite/rpl/t/rpl_row_ignorable_event.test	2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_ignorable_event.test	2011-01-19 06:58:42 +0000
@@ -13,8 +13,6 @@ source include/have_binlog_rows_query.in
 source include/have_innodb.inc;
 source include/have_debug.inc;
 
-SET @old_debug= @@global.debug;
-SET GLOBAL debug="+d,waiting_for_delayed_insert_queue_is_empty";
 --echo # Test non-transaction
 let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
 let $master_binlog= query_get_value(SHOW MASTER STATUS, File, 1);
@@ -60,6 +58,10 @@ insert into t5(a, b) values(3,1);
 --echo # out all its related tables by replication filtering rules
 update t4,t5 set t4.a=4, t5.a=5 where t4.b=t5.b;
 
+SET @old_debug= @@global.debug;
+SET GLOBAL debug="+d,after_handle_inserts";
+set DEBUG_SYNC= 'before_write_delayed SIGNAL before_insert EXECUTE 3';
+set DEBUG_SYNC= 'after_write_delayed WAIT_FOR inserts_handled EXECUTE 3';
 --echo # Test insert delayed ...
 let $table=t3;
 insert delayed into t3(a,b) values(1,5),(1,6),(1,7);

=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc	2010-12-22 13:23:59 +0000
+++ b/sql/sql_insert.cc	2011-01-19 06:58:42 +0000
@@ -75,6 +75,7 @@
 #include "rpl_mi.h"
 #include "transaction.h"
 #include "sql_audit.h"
+#include "debug_sync.h"
 
 #ifndef EMBEDDED_LIBRARY
 static bool delayed_get_table(THD *thd, MDL_request *grl_protection_request,
@@ -920,7 +921,9 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
     if (lock_type == TL_WRITE_DELAYED)
     {
       LEX_STRING const st_query = { query, thd->query_length() };
+      DEBUG_SYNC(thd, "before_write_delayed");
       error=write_delayed(thd, table, duplic, st_query, ignore, log_on);
+      DEBUG_SYNC(thd, "after_write_delayed");
       query=0;
     }
     else
@@ -2867,7 +2870,6 @@ bool Delayed_insert::handle_inserts(void
 
   /* Allow client to insert new rows */
   mysql_mutex_unlock(&mutex);
-
   table->next_number_field=table->found_next_number_field;
 
   thd_proc_info(&thd, "upgrading lock");
@@ -3103,6 +3105,15 @@ bool Delayed_insert::handle_inserts(void
     goto err;
   }
   query_cache_invalidate3(&thd, table, 1);
+  DBUG_EXECUTE_IF("after_handle_inserts",
+                  {
+                    const char act[]=
+                      "now "
+                      "signal inserts_handled";
+                    DBUG_ASSERT(opt_debug_sync_timeout > 0);
+                    DBUG_ASSERT(!debug_sync_set_action(&thd,
+                                                       STRING_WITH_LEN(act)));
+                  };);
   mysql_mutex_lock(&mutex);
   DBUG_RETURN(0);
 


Attachment: [text/bzr-bundle] bzr/daogang.qu@greatopensource.com-20110119065842-j486frjvpef59r06.bundle
Thread
bzr commit into mysql-trunk branch (daogang.qu:3454) Bug#58784daogang.qu19 Jan