From: daogang.qu Date: January 21 2011 11:30am Subject: bzr commit into mysql-trunk branch (daogang.qu:3540) Bug#58784 List-Archive: http://lists.mysql.com/commits/129322 X-Bug: 58784 Message-Id: <201101211130.p0LBUwwk009150@localhost6.localdomain6> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5897036452271439979==" --===============5897036452271439979== 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 3540 daogang.qu@stripped 2011-01-21 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-21 11:30:47 +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-21 11:30:47 +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-21 11:30:47 +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 @@ -2345,8 +2348,6 @@ int write_delayed(THD *thd, TABLE *table (ulong) query.length)); thd_proc_info(thd, "waiting for handler insert"); - DBUG_EXECUTE_IF("waiting_for_delayed_insert_queue_is_empty", - while(di->stacked_inserts) sleep(1);); mysql_mutex_lock(&di->mutex); while (di->stacked_inserts >= delayed_queue_size && !thd->killed) mysql_cond_wait(&di->cond_client, &di->mutex); @@ -3103,6 +3104,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); --===============5897036452271439979== 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\ # wh7mf5d6t41qzj1e # target_branch: file:///home/daogang/bzrwork/bug58784/mysql-trunk/ # testament_sha1: 9e486d15ac64d40fb6eee0d63711fddc0c0ff07a # timestamp: 2011-01-21 19:30:58 +0800 # base_revision_id: marc.alff@stripped\ # gu0nysksnm7zloem # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWTV1dqEAA91/gHAxUAB57/// f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