List:Commits« Previous MessageNext Message »
From:cbell Date:August 22 2007 8:44pm
Subject:bk commit into 5.1 tree (cbell:1.2566) BUG#29020
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of cbell. When cbell does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-08-22 16:43:36-04:00, cbell@mysql_cab_desk. +7 -0
  BUG#29020 : Test: Event results not replicated to slave in RBR
  
  Patch adds new methods to initiate locks on the binlog. These locks are
  used to ensure a table map / row event pair are written as a pair and 
  prevent interleaving of the events.

  mysql-test/suite/rpl/r/rpl_invoked_features.result@stripped, 2007-08-22 16:42:59-04:00, cbell@mysql_cab_desk. +9 -14
    BUG#29020 : Test: Event results not replicated to slave in RBR
    
    New result file for modified test.

  mysql-test/suite/rpl/t/disabled.def@stripped, 2007-08-22 16:42:59-04:00, cbell@mysql_cab_desk. +0 -1
    BUG#29020 : Test: Event results not replicated to slave in RBR
    
    Removed rpl_invoked_features from disabled tests list.

  mysql-test/suite/rpl/t/rpl_invoked_features.test@stripped, 2007-08-22 16:43:00-04:00, cbell@mysql_cab_desk. +20 -19
    BUG#29020 : Test: Event results not replicated to slave in RBR
    
    This patch includes minor modifications to this test to ensure the 
    events are fired at least once. Some logic removed from events for
    simplification. Added order by clause to remove possible deterministic
    problems with result set from query.

  sql/log.cc@stripped, 2007-08-22 16:43:00-04:00, cbell@mysql_cab_desk. +41 -0
    BUG#29020 : Test: Event results not replicated to slave in RBR
    
    Patch adds new methods to initiate locks on the binlog. These locks are
    used to ensure a table map / row event pair are written as a pair and 
    prevent interleaving of the events. 

  sql/log.h@stripped, 2007-08-22 16:43:01-04:00, cbell@mysql_cab_desk. +23 -0
    BUG#29020 : Test: Event results not replicated to slave in RBR
    
    Patch adds new method declarations to initiate locks on the binlog.

  sql/sql_class.cc@stripped, 2007-08-22 16:43:02-04:00, cbell@mysql_cab_desk. +6 -1
    BUG#29020 : Test: Event results not replicated to slave in RBR
    
    Patch initializes thread variables for detecting when the new binlog lock 
    methods are called.

  sql/sql_class.h@stripped, 2007-08-22 16:43:02-04:00, cbell@mysql_cab_desk. +14 -0
    BUG#29020 : Test: Event results not replicated to slave in RBR
    
    Patch initializes thread variables for detecting when the new binlog lock 
    methods are called.

diff -Nrup a/mysql-test/suite/rpl/r/rpl_invoked_features.result b/mysql-test/suite/rpl/r/rpl_invoked_features.result
--- a/mysql-test/suite/rpl/r/rpl_invoked_features.result	2007-06-27 08:44:13 -04:00
+++ b/mysql-test/suite/rpl/r/rpl_invoked_features.result	2007-08-22 16:42:59 -04:00
@@ -49,21 +49,13 @@ BEGIN
 UPDATE t12 SET c = '';
 UPDATE t13 SET c = '';
 END|
-CREATE EVENT e1 ON SCHEDULE EVERY 1 SECOND ENABLE DO
+CREATE EVENT e1 ON SCHEDULE EVERY 2 SECOND ENABLE DO
 BEGIN
-DECLARE c INT;
-SELECT a INTO c FROM t1 WHERE a < 11 ORDER BY a DESC LIMIT 1;
-IF c = 7 THEN
 CALL p1(10, '');  
-END IF;
 END|
-CREATE EVENT e11 ON SCHEDULE EVERY 1 SECOND ENABLE DO
+CREATE EVENT e11 ON SCHEDULE EVERY 2 SECOND ENABLE DO
 BEGIN
-DECLARE c INT;
-SELECT a INTO c FROM t11 WHERE a < 11 ORDER BY a DESC LIMIT 1;
-IF c = 7 THEN
 CALL p11(10, '');  
-END IF;
 END|
 CREATE FUNCTION f1 (x INT) RETURNS VARCHAR(64)
 BEGIN
@@ -78,11 +70,11 @@ RETURN f1(x);
 END|
 CREATE PROCEDURE p1 (IN x INT, IN y VARCHAR(64))
 BEGIN
-INSERT INTO t1 VALUES (x,x,y);
+INSERT IGNORE INTO t1 VALUES (x,x,y);
 END|
 CREATE PROCEDURE p11 (IN x INT, IN y VARCHAR(64))
 BEGIN
-INSERT INTO t11 VALUES (x,x,y);
+INSERT IGNORE INTO t11 VALUES (x,x,y);
 END|
 
 CREATE TABLE t3 SELECT * FROM v1;
@@ -110,6 +102,9 @@ INSERT INTO t11 VALUES(7,7,f2(7));
 INSERT INTO t11 VALUES (103,103,'');
 
 SET GLOBAL EVENT_SCHEDULER = on;
+SELECT COUNT(*) = 1 FROM t11 WHERE t11.a = 10;
+COUNT(*) = 1
+1
 SET GLOBAL EVENT_SCHEDULER = off;
 
 SHOW TABLES LIKE 't%';
@@ -136,7 +131,7 @@ FUNCTION	f1
 FUNCTION	f2
 PROCEDURE	p1
 PROCEDURE	p11
-SELECT event_name, status FROM information_schema.events WHERE event_schema='test';
+SELECT event_name, status FROM information_schema.events WHERE event_schema='test' order by event_name;
 event_name	status
 e1	ENABLED
 e11	ENABLED
@@ -296,7 +291,7 @@ FUNCTION	f1
 FUNCTION	f2
 PROCEDURE	p1
 PROCEDURE	p11
-SELECT event_name, status FROM information_schema.events WHERE event_schema='test';
+SELECT event_name, status FROM information_schema.events WHERE event_schema='test' order by event_name;
 event_name	status
 e1	SLAVESIDE_DISABLED
 e11	SLAVESIDE_DISABLED
diff -Nrup a/mysql-test/suite/rpl/t/disabled.def b/mysql-test/suite/rpl/t/disabled.def
--- a/mysql-test/suite/rpl/t/disabled.def	2007-08-02 16:15:43 -04:00
+++ b/mysql-test/suite/rpl/t/disabled.def	2007-08-22 16:42:59 -04:00
@@ -13,7 +13,6 @@
 rpl_ddl                  : BUG#26418 2007-03-01 mleich Slave out of sync after CREATE/DROP TEMPORARY TABLE + ROLLBACK on master
 rpl_innodb_mixed_ddl     : Bug #29363 rpl.rpl_innodb_mixed_* test failures
 rpl_innodb_mixed_dml     : Bug #29363 rpl.rpl_innodb_mixed_* test failures
-rpl_invoked_features     : BUG#29020 2007-06-21 Lars Non-deterministic test case
 rpl_auto_increment_11932   : Bug#29809 2007-07-16 ingo Slave SQL errors in warnings file
 rpl_stm_extraColmaster_ndb : WL#3915 : Statement-based replication not supported in ndb. Enable test when supported.
 rpl_row_extraColmaster_ndb : BUG#29549 : Replication of BLOBs fail for NDB
diff -Nrup a/mysql-test/suite/rpl/t/rpl_invoked_features.test b/mysql-test/suite/rpl/t/rpl_invoked_features.test
--- a/mysql-test/suite/rpl/t/rpl_invoked_features.test	2007-06-27 08:44:05 -04:00
+++ b/mysql-test/suite/rpl/t/rpl_invoked_features.test	2007-08-22 16:43:00 -04:00
@@ -95,23 +95,15 @@ BEGIN
   UPDATE t13 SET c = '';
 END|
 
-# Create events which will run every 1 sec
-CREATE EVENT e1 ON SCHEDULE EVERY 1 SECOND ENABLE DO
+# Create events which will run every 2 sec
+CREATE EVENT e1 ON SCHEDULE EVERY 2 SECOND ENABLE DO
 BEGIN
-  DECLARE c INT;
-  SELECT a INTO c FROM t1 WHERE a < 11 ORDER BY a DESC LIMIT 1;
-  IF c = 7 THEN
-    CALL p1(10, '');  
-  END IF;
+  CALL p1(10, '');  
 END|
 
-CREATE EVENT e11 ON SCHEDULE EVERY 1 SECOND ENABLE DO
+CREATE EVENT e11 ON SCHEDULE EVERY 2 SECOND ENABLE DO
 BEGIN
-  DECLARE c INT;
-  SELECT a INTO c FROM t11 WHERE a < 11 ORDER BY a DESC LIMIT 1;
-  IF c = 7 THEN
-    CALL p11(10, '');  
-  END IF;
+  CALL p11(10, '');  
 END|
 
 # Create functions and procedures used for events
@@ -130,12 +122,12 @@ END|
 
 CREATE PROCEDURE p1 (IN x INT, IN y VARCHAR(64))
 BEGIN
-  INSERT INTO t1 VALUES (x,x,y);
+  INSERT IGNORE INTO t1 VALUES (x,x,y);
 END|
 
 CREATE PROCEDURE p11 (IN x INT, IN y VARCHAR(64))
 BEGIN
-  INSERT INTO t11 VALUES (x,x,y);
+  INSERT IGNORE INTO t11 VALUES (x,x,y);
 END|
 
 DELIMITER ;|
@@ -178,8 +170,17 @@ INSERT INTO t11 VALUES (103,103,'');
 # Scheduler is on
 --echo
 SET GLOBAL EVENT_SCHEDULER = on;
-# Wait 2 sec while events will executed
---sleep 2
+
+# Wait until event e1 has fired. We know this because t1 and t11 will 
+# contain the rows from the events e1 and e11.
+let $wait_condition=
+  SELECT COUNT(*) = 1 FROM t1 WHERE t1.a = 10;
+--source include/wait_condition.inc
+
+#let $wait_condition=
+  SELECT COUNT(*) = 1 FROM t11 WHERE t11.a = 10;
+--source include/wait_condition.inc
+
 SET GLOBAL EVENT_SCHEDULER = off;
 
 # Check original objects
@@ -188,7 +189,7 @@ SHOW TABLES LIKE 't%';
 SELECT table_name FROM information_schema.views WHERE table_schema='test';
 SELECT trigger_name, event_manipulation, event_object_table FROM information_schema.triggers WHERE trigger_schema='test';
 SELECT routine_type, routine_name FROM information_schema.routines WHERE routine_schema='test';
-SELECT event_name, status FROM information_schema.events WHERE event_schema='test';
+SELECT event_name, status FROM information_schema.events WHERE event_schema='test' order by event_name;
 
 # Check original data
 --echo
@@ -215,7 +216,7 @@ SHOW TABLES LIKE 't%';
 SELECT table_name FROM information_schema.views WHERE table_schema='test';
 SELECT trigger_name, event_manipulation, event_object_table FROM information_schema.triggers WHERE trigger_schema='test';
 SELECT routine_type, routine_name FROM information_schema.routines WHERE routine_schema='test';
-SELECT event_name, status FROM information_schema.events WHERE event_schema='test';
+SELECT event_name, status FROM information_schema.events WHERE event_schema='test' order by event_name;
 
 # Check replicated data
 --echo
diff -Nrup a/sql/log.cc b/sql/log.cc
--- a/sql/log.cc	2007-08-03 10:54:34 -04:00
+++ b/sql/log.cc	2007-08-22 16:43:00 -04:00
@@ -1785,6 +1785,7 @@ void MYSQL_LOG::init_pthread_objects()
   DBUG_ASSERT(inited == 0);
   inited= 1;
   (void) pthread_mutex_init(&LOCK_log, MY_MUTEX_INIT_SLOW);
+  (void) pthread_mutex_init(&LOCK_log_multi, MY_MUTEX_INIT_SLOW);
 }
 
 /*
@@ -1836,6 +1837,7 @@ void MYSQL_LOG::cleanup()
   {
     inited= 0;
     (void) pthread_mutex_destroy(&LOCK_log);
+    (void) pthread_mutex_destroy(&LOCK_log_multi);
     close(0);
   }
   DBUG_VOID_RETURN;
@@ -2208,6 +2210,7 @@ void MYSQL_BIN_LOG::cleanup()
     delete description_event_for_queue;
     delete description_event_for_exec;
     (void) pthread_mutex_destroy(&LOCK_log);
+    (void) pthread_mutex_destroy(&LOCK_log_multi);
     (void) pthread_mutex_destroy(&LOCK_index);
     (void) pthread_cond_destroy(&update_cond);
   }
@@ -2231,6 +2234,7 @@ void MYSQL_BIN_LOG::init_pthread_objects
   DBUG_ASSERT(inited == 0);
   inited= 1;
   (void) pthread_mutex_init(&LOCK_log, MY_MUTEX_INIT_SLOW);
+  (void) pthread_mutex_init(&LOCK_log_multi, MY_MUTEX_INIT_SLOW);
   (void) pthread_mutex_init(&LOCK_index, MY_MUTEX_INIT_SLOW);
   (void) pthread_cond_init(&update_cond, 0);
 }
@@ -3065,6 +3069,7 @@ void MYSQL_BIN_LOG::new_file_impl(bool n
   pthread_mutex_lock(&LOCK_index);
 
   safe_mutex_assert_owner(&LOCK_log);
+  safe_mutex_assert_owner(&LOCK_log_multi);
   safe_mutex_assert_owner(&LOCK_index);
 
   /*
@@ -3187,6 +3192,7 @@ bool MYSQL_BIN_LOG::appendv(const char* 
   DBUG_ASSERT(log_file.type == SEQ_READ_APPEND);
 
   safe_mutex_assert_owner(&LOCK_log);
+  safe_mutex_assert_owner(&LOCK_log_multi);
   do
   {
     if (my_b_append(&log_file,(uchar*) buf,len))
@@ -3211,6 +3217,7 @@ bool MYSQL_BIN_LOG::flush_and_sync()
 {
   int err=0, fd=log_file.file;
   safe_mutex_assert_owner(&LOCK_log);
+  safe_mutex_assert_owner(&LOCK_log_multi);
   if (flush_io_cache(&log_file))
     return 1;
   if (++sync_binlog_counter >= sync_binlog_period && sync_binlog_period)
@@ -3389,9 +3396,13 @@ int THD::binlog_write_table_map(TABLE *t
   Table_map_log_event
     the_event(this, table, table->s->table_map_id, is_trans, flags);
 
+  binlog_in_trans= is_trans;
+
   if (is_trans && binlog_table_maps == 0)
     binlog_start_trans_and_stmt();
 
+  mysql_bin_log.binlog_begin_stmt();
+
   if ((error= mysql_bin_log.write(&the_event)))
     DBUG_RETURN(error);
 
@@ -3514,6 +3525,36 @@ MYSQL_BIN_LOG::flush_and_set_pending_row
   thd->binlog_set_pending_rows_event(event);
 
   DBUG_RETURN(error);
+}
+
+/*
+  Start a mutex lock for the binlog.
+*/
+bool MYSQL_BIN_LOG::binlog_begin_stmt()
+{
+  DBUG_ENTER("MYSQL_BIN_LOG::binlog_begin_stmt()");
+  THD *thd= current_thd;
+  if (!thd->binlog_lock_taken && !thd->binlog_in_trans)
+  {
+    thd->binlog_lock_taken= TRUE;
+    pthread_mutex_lock(&LOCK_log_multi);
+  }
+  DBUG_RETURN(0);
+}
+
+/*
+  End a mutex lock for the binlog.
+*/
+bool MYSQL_BIN_LOG::binlog_end_stmt()
+{
+  DBUG_ENTER("MYSQL_BIN_LOG::binlog_end_stmt()");
+  THD *thd= current_thd;
+  if (thd->binlog_lock_taken)
+  {
+    pthread_mutex_unlock(&LOCK_log_multi);
+    thd->binlog_lock_taken= FALSE;
+  }
+  DBUG_RETURN(0);
 }
 
 /*
diff -Nrup a/sql/log.h b/sql/log.h
--- a/sql/log.h	2007-08-02 00:50:52 -04:00
+++ b/sql/log.h	2007-08-22 16:43:01 -04:00
@@ -176,6 +176,7 @@ public:
  protected:
   /* LOCK_log is inited by init_pthread_objects() */
   pthread_mutex_t LOCK_log;
+  pthread_mutex_t LOCK_log_multi;
   char *name;
   char log_file_name[FN_REFLEN];
   char time_buff[20], db[NAME_LEN + 1];
@@ -337,6 +338,28 @@ public:
   /* Use this to start writing a new log file */
   void new_file();
 
+/**
+  Start a mutex lock for the binlog.
+
+  This method locks the LOCK_log mutex when called. It can be used to ensure a
+  sequence of operations on the binlog are accomplished as a set. This is
+  necessary for cases where multiple threads write two or more events to the
+  binlog. In this case, we want to avoid any interleaving of the events among
+  the threads. A guard is used to ensure the lock is taken only once per thread
+  and only when executing non-transactional statements.
+
+  @returns 0.
+*/
+  bool binlog_begin_stmt();
+
+/**
+  End a mutex lock for the binlog.
+
+  This methods unlocks the LOCK_log mutex locked by binlog_begin_stmt().
+
+  @returns 0.
+*/
+  bool binlog_end_stmt();
   bool write(Log_event* event_info); // binary log write
   bool write(THD *thd, IO_CACHE *cache, Log_event *commit_event);
 
diff -Nrup a/sql/sql_class.cc b/sql/sql_class.cc
--- a/sql/sql_class.cc	2007-08-03 10:54:35 -04:00
+++ b/sql/sql_class.cc	2007-08-22 16:43:02 -04:00
@@ -375,7 +375,9 @@ THD::THD()
    bootstrap(0),
    derived_tables_processing(FALSE),
    spcont(NULL),
-   m_lip(NULL)
+   m_lip(NULL),
+   binlog_lock_taken(FALSE),
+   binlog_in_trans(FALSE)
 {
   ulong tmp;
 
@@ -3242,6 +3244,9 @@ int THD::binlog_flush_pending_rows_event
     }
 
     error= mysql_bin_log.flush_and_set_pending_rows_event(this, 0);
+
+    if (stmt_end)
+      mysql_bin_log.binlog_end_stmt();
   }
 
   DBUG_RETURN(error);
diff -Nrup a/sql/sql_class.h b/sql/sql_class.h
--- a/sql/sql_class.h	2007-08-03 10:54:35 -04:00
+++ b/sql/sql_class.h	2007-08-22 16:43:02 -04:00
@@ -1125,6 +1125,20 @@ public:
   void            binlog_set_pending_rows_event(Rows_log_event* ev);
   int binlog_flush_pending_rows_event(bool stmt_end);
 
+  /* 
+    This variable is used to ensure the mutex lock on LOCK_log for the
+    binlog is taken only once per thread. It is used in conjunction with 
+    binlog_is_trans in MYSQL_BIN_LOG::binlog_begin_stmt().
+  */
+  my_bool binlog_lock_taken;
+
+  /* 
+    This variable is used to ensure the mutex lock on LOCK_log for the
+    binlog is taken when executing non-transactional statements. It is used
+    in conjunction with binlog_lock_taken in MYSQL_BIN_LOG::binlog_begin_stmt().
+  */
+  my_bool binlog_in_trans;
+
 private:
   uint binlog_table_maps; // Number of table maps currently in the binlog
 

Thread
bk commit into 5.1 tree (cbell:1.2566) BUG#29020cbell22 Aug
  • Re: bk commit into 5.1 tree (cbell:1.2566) BUG#29020Konstantin Osipov23 Aug
    • RE: bk commit into 5.1 tree (cbell:1.2566) BUG#29020Chuck Bell23 Aug