From: daogang.qu Date: January 19 2011 6:58am Subject: bzr commit into mysql-trunk branch (daogang.qu:3454) Bug#58784 List-Archive: http://lists.mysql.com/commits/129136 X-Bug: 58784 Message-Id: <201101190658.p0J6wmbm020606@localhost6.localdomain6> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8577126542857137514==" --===============8577126542857137514== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #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); --===============8577126542857137514== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/daogang.qu@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: daogang.qu@stripped\ # j486frjvpef59r06 # target_branch: file:///home/daogang/bzrwork/bug58784/mysql-trunk/ # testament_sha1: ec861a9b86cf6c61b53dd6e83ce169fd867985eb # timestamp: 2011-01-19 14:58:48 +0800 # base_revision_id: marc.alff@stripped\ # yab7b8mxeng998ia # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWZtUHtIAA+j/gFAxUAB57/// f+Xe6r////pgCYfe3HbPiA6Bbt3e9r3q12zaHXdu7FomAkpoUyTxBTyZPTSanqP0aU09EZAAMmmm CBoeUCSQCMgJojQ0TMhTT1TBB6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