MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Mats Kindahl Date:October 19 2007 12:18pm
Subject:bk commit into 5.1 tree (mats:1.2578) BUG#28618
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of mats. When mats 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-10-19 14:18:41+02:00, mats@stripped +10 -0
  BUG#28618 (Skipping into the middle of a group with SQL_SLAVE_SKIP_COUNTER
  is possible):
  
  When skipping the beginning of a transaction starting with BEGIN, the OPTION_BEGIN
  flag was not set correctly, which caused the slave to not recognize that it was
  inside a group. This patch sets the OPTION_BEGIN flag for BEGIN, COMMIT, ROLLBACK,
  and XID events. It also adds checks if inside a group before decreasing the
  slave skip counter to zero.
  
  Begin_query_log_event was not marked that it could not end a group, which is now
  corrected.

  mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test@stripped, 2007-10-19 14:18:30+02:00, mats@stripped +3 -1
    Correcting slave skip counter to get the correct behaviour.

  mysql-test/suite/rpl/data/rpl_bug28618.dat@stripped, 2007-10-19 14:18:34+02:00, mats@stripped +3 -0
    New BitKeeper file ``mysql-test/suite/rpl/data/rpl_bug28618.dat''

  mysql-test/suite/rpl/data/rpl_bug28618.dat@stripped, 2007-10-19 14:18:34+02:00, mats@stripped +0 -0

  mysql-test/suite/rpl/r/rpl_slave_skip.result@stripped, 2007-10-19 14:18:30+02:00, mats@stripped +208 -0
    Result change.

  mysql-test/suite/rpl/t/rpl_slave_skip-slave.opt@stripped, 2007-10-19 14:18:34+02:00, mats@stripped +1 -0
    New BitKeeper file ``mysql-test/suite/rpl/t/rpl_slave_skip-slave.opt''

  mysql-test/suite/rpl/t/rpl_slave_skip-slave.opt@stripped, 2007-10-19 14:18:34+02:00, mats@stripped +0 -0

  mysql-test/suite/rpl/t/rpl_slave_skip.test@stripped, 2007-10-19 14:18:30+02:00, mats@stripped +239 -0
    Adding tests to check that skipping works for transactions:
    - Skipping one group with BEGIN first
    - Skipping two groups with BEGIN first
    - Skipping one group without BEGIN first but with AUTOCOMMIT=0
    - LOAD DATA INFILE under statement-based replication

  mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result@stripped, 2007-10-19 14:18:31+02:00, mats@stripped +1 -1
    Result change.

  sql/log_event.cc@stripped, 2007-10-19 14:18:33+02:00, mats@stripped +64 -17
    Adding checks if we're in a group when the slave skip counter is 1.
    In that case, we should keep going.
    
    Adding helping member function Log_event::continue_group() denoting
    that this event cannot end a group, and if the skip counter indicates
    that the group ends after this event, it should not decrease the skip
    counter.
    
    Query_log_event will change the OPTION_BEGIN flag for BEGIN, COMMIT, and
    ROLLBACK, even when skipping because of a positive skip count, and
    Xid_log_event will also affect the OPTION_BEGIN flag, even when being
    skipped.
    
    Begin_load_query_log_event cannot end a group, so it is marked to
    continue the group.

  sql/log_event.h@stripped, 2007-10-19 14:18:33+02:00, mats@stripped +25 -0
    Adding helper function Log_event::continue_group().

  sql/rpl_rli.h@stripped, 2007-10-19 14:18:33+02:00, mats@stripped +12 -0
    Adding Relay_log_info::get_flag() to get the value of a
    replication flag.

  sql/slave.cc@stripped, 2007-10-19 14:18:34+02:00, mats@stripped +4 -1
    Adding debug output and changing debug message.

diff -Nrup a/mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test b/mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test
--- a/mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test	2007-08-10 18:46:35 +02:00
+++ b/mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test	2007-10-19 14:18:30 +02:00
@@ -736,13 +736,15 @@ connection slave;
 --replace_result $MASTER_MYPORT MASTER_PORT
 --replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #
 --query_vertical SHOW SLAVE STATUS
-SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
 START SLAVE;
 
 --echo *** Try to insert in master ****
 connection master;
 INSERT INTO t15 () VALUES(5,2.00,'Replication Testing',@b1,'Buda',2);
 SELECT * FROM t15 ORDER BY c1;
+
+#SHOW BINLOG EVENTS;
 
 --echo *** Try to select from slave ****
 sync_slave_with_master;
diff -Nrup a/mysql-test/suite/rpl/data/rpl_bug28618.dat b/mysql-test/suite/rpl/data/rpl_bug28618.dat
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/suite/rpl/data/rpl_bug28618.dat	2007-10-19 14:18:34 +02:00
@@ -0,0 +1,3 @@
+1|master only
+2|master only
+3|master only
diff -Nrup a/mysql-test/suite/rpl/r/rpl_slave_skip.result b/mysql-test/suite/rpl/r/rpl_slave_skip.result
--- a/mysql-test/suite/rpl/r/rpl_slave_skip.result	2007-07-30 13:32:04 +02:00
+++ b/mysql-test/suite/rpl/r/rpl_slave_skip.result	2007-10-19 14:18:30 +02:00
@@ -142,3 +142,211 @@ Last_SQL_Errno	0
 Last_SQL_Error	
 **** On Master ****
 DROP TABLE t1, t2;
+SET SESSION BINLOG_FORMAT=ROW;
+SET AUTOCOMMIT=0;
+CREATE TABLE t1 (a INT, b VARCHAR(20)) ENGINE=myisam;
+CREATE TABLE t2 (a INT, b VARCHAR(20)) ENGINE=myisam;
+CREATE TABLE t3 (a INT, b VARCHAR(20)) ENGINE=myisam;
+INSERT INTO t1 VALUES (1,'master/slave');
+INSERT INTO t2 VALUES (1,'master/slave');
+INSERT INTO t3 VALUES (1,'master/slave');
+CREATE TRIGGER tr1 AFTER UPDATE on t1 FOR EACH ROW
+BEGIN
+INSERT INTO t2 VALUES (NEW.a,NEW.b);
+DELETE FROM t2 WHERE a < NEW.a;
+END|
+CREATE TRIGGER tr2 AFTER INSERT on t2 FOR EACH ROW
+BEGIN
+UPDATE t3 SET a =2, b = 'master only';
+END|
+**** On Slave ****
+STOP SLAVE;
+**** On Master ****
+UPDATE t1 SET a = 2, b = 'master only' WHERE a = 1;
+DROP TRIGGER tr1;
+DROP TRIGGER tr2;
+INSERT INTO t1 VALUES (3,'master/slave');
+INSERT INTO t2 VALUES (3,'master/slave');
+INSERT INTO t3 VALUES (3,'master/slave');
+SELECT * FROM t1 ORDER BY a;
+a	b
+2	master only
+3	master/slave
+SELECT * FROM t2 ORDER BY a;
+a	b
+2	master only
+3	master/slave
+SELECT * FROM t3 ORDER BY a;
+a	b
+2	master only
+3	master/slave
+*** On Slave ***
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
+START SLAVE;
+SELECT * FROM t1 ORDER BY a;
+a	b
+1	master/slave
+3	master/slave
+SELECT * FROM t2 ORDER BY a;
+a	b
+1	master/slave
+3	master/slave
+SELECT * FROM t3 ORDER BY a;
+a	b
+1	master/slave
+3	master/slave
+DROP TABLE t1, t2, t3;
+**** Case 2: Row binlog format and transactional tables ****
+*** On Master ***
+CREATE TABLE t4 (a INT, b VARCHAR(20)) ENGINE=innodb;
+CREATE TABLE t5 (a INT, b VARCHAR(20)) ENGINE=innodb;
+CREATE TABLE t6 (a INT, b VARCHAR(20)) ENGINE=innodb;
+**** On Slave ****
+STOP SLAVE;
+*** On Master ***
+BEGIN;
+INSERT INTO t4 VALUES (2, 'master only');
+INSERT INTO t5 VALUES (2, 'master only');
+INSERT INTO t6 VALUES (2, 'master only');
+COMMIT;
+BEGIN;
+INSERT INTO t4 VALUES (3, 'master/slave');
+INSERT INTO t5 VALUES (3, 'master/slave');
+INSERT INTO t6 VALUES (3, 'master/slave');
+COMMIT;
+SELECT * FROM t4 ORDER BY a;
+a	b
+2	master only
+3	master/slave
+SELECT * FROM t5 ORDER BY a;
+a	b
+2	master only
+3	master/slave
+SELECT * FROM t6 ORDER BY a;
+a	b
+2	master only
+3	master/slave
+*** On Slave ***
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
+START SLAVE;
+SELECT * FROM t4 ORDER BY a;
+a	b
+3	master/slave
+SELECT * FROM t5 ORDER BY a;
+a	b
+3	master/slave
+SELECT * FROM t6 ORDER BY a;
+a	b
+3	master/slave
+**** On Slave ****
+STOP SLAVE;
+*** On Master ***
+BEGIN;
+INSERT INTO t4 VALUES (6, 'master only');
+INSERT INTO t5 VALUES (6, 'master only');
+INSERT INTO t6 VALUES (6, 'master only');
+COMMIT;
+BEGIN;
+INSERT INTO t4 VALUES (7, 'master only');
+INSERT INTO t5 VALUES (7, 'master only');
+INSERT INTO t6 VALUES (7, 'master only');
+COMMIT;
+SELECT * FROM t4 ORDER BY a;
+a	b
+2	master only
+3	master/slave
+6	master only
+7	master only
+SELECT * FROM t5 ORDER BY a;
+a	b
+2	master only
+3	master/slave
+6	master only
+7	master only
+SELECT * FROM t6 ORDER BY a;
+a	b
+2	master only
+3	master/slave
+6	master only
+7	master only
+*** On Slave ***
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=10;
+START SLAVE;
+SELECT * FROM t4 ORDER BY a;
+a	b
+3	master/slave
+SELECT * FROM t5 ORDER BY a;
+a	b
+3	master/slave
+SELECT * FROM t6 ORDER BY a;
+a	b
+3	master/slave
+STOP SLAVE;
+SET AUTOCOMMIT=0;
+INSERT INTO t4 VALUES (4, 'master only');
+INSERT INTO t5 VALUES (4, 'master only');
+INSERT INTO t6 VALUES (4, 'master only');
+COMMIT;
+INSERT INTO t4 VALUES (5, 'master/slave');
+INSERT INTO t5 VALUES (5, 'master/slave');
+INSERT INTO t6 VALUES (5, 'master/slave');
+COMMIT;
+SELECT * FROM t4 ORDER BY a;
+a	b
+2	master only
+3	master/slave
+4	master only
+5	master/slave
+6	master only
+7	master only
+SELECT * FROM t5 ORDER BY a;
+a	b
+2	master only
+3	master/slave
+4	master only
+5	master/slave
+6	master only
+7	master only
+SELECT * FROM t6 ORDER BY a;
+a	b
+2	master only
+3	master/slave
+4	master only
+5	master/slave
+6	master only
+7	master only
+*** On Slave ***
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
+START SLAVE;
+SELECT * FROM t4 ORDER BY a;
+a	b
+3	master/slave
+5	master/slave
+SELECT * FROM t5 ORDER BY a;
+a	b
+3	master/slave
+5	master/slave
+SELECT * FROM t6 ORDER BY a;
+a	b
+3	master/slave
+5	master/slave
+DROP TABLE t4, t5, t6;
+**** Case 3: Statement logging format and LOAD DATA with non-transactional table ****
+*** On Master ***
+CREATE TABLE t10 (a INT, b VARCHAR(20)) ENGINE=myisam;
+*** On Slave ***
+STOP SLAVE;
+*** On Master ***
+SET SESSION BINLOG_FORMAT=STATEMENT;
+LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/rpl_bug28618.dat' INTO TABLE t10 FIELDS TERMINATED BY '|';
+SELECT * FROM t10 ORDER BY a;
+a	b
+1	master only
+2	master only
+3	master only
+*** On Slave ***
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
+START SLAVE;
+SELECT * FROM t10 ORDER BY a;
+a	b
+DROP TABLE t10;
diff -Nrup a/mysql-test/suite/rpl/t/rpl_slave_skip-slave.opt b/mysql-test/suite/rpl/t/rpl_slave_skip-slave.opt
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/suite/rpl/t/rpl_slave_skip-slave.opt	2007-10-19 14:18:34 +02:00
@@ -0,0 +1 @@
+--innodb
diff -Nrup a/mysql-test/suite/rpl/t/rpl_slave_skip.test b/mysql-test/suite/rpl/t/rpl_slave_skip.test
--- a/mysql-test/suite/rpl/t/rpl_slave_skip.test	2007-06-27 14:44:05 +02:00
+++ b/mysql-test/suite/rpl/t/rpl_slave_skip.test	2007-10-19 14:18:30 +02:00
@@ -1,7 +1,9 @@
 source include/master-slave.inc;
+source include/have_innodb.inc;
 
 --echo **** On Slave ****
 connection slave;
+source include/have_innodb.inc;
 STOP SLAVE;
 
 --echo **** On Master ****
@@ -69,3 +71,240 @@ query_vertical SHOW SLAVE STATUS;
 connection master;
 DROP TABLE t1, t2;
 sync_slave_with_master;
+
+#
+# More tests for BUG#28618
+#
+# Case 1.
+# ROW binlog format and non-transactional tables.
+# Create the group of events via triggers and try to skip 
+# some items of that group.
+#  
+
+connection master;
+SET SESSION BINLOG_FORMAT=ROW;
+SET AUTOCOMMIT=0;
+
+CREATE TABLE t1 (a INT, b VARCHAR(20)) ENGINE=myisam;
+CREATE TABLE t2 (a INT, b VARCHAR(20)) ENGINE=myisam;
+CREATE TABLE t3 (a INT, b VARCHAR(20)) ENGINE=myisam;
+
+INSERT INTO t1 VALUES (1,'master/slave');
+INSERT INTO t2 VALUES (1,'master/slave');
+INSERT INTO t3 VALUES (1,'master/slave');
+
+DELIMITER |;
+
+CREATE TRIGGER tr1 AFTER UPDATE on t1 FOR EACH ROW
+BEGIN
+  INSERT INTO t2 VALUES (NEW.a,NEW.b);
+  DELETE FROM t2 WHERE a < NEW.a;
+END|
+
+CREATE TRIGGER tr2 AFTER INSERT on t2 FOR EACH ROW
+BEGIN
+  UPDATE t3 SET a =2, b = 'master only';
+END|
+
+DELIMITER ;|
+
+--echo **** On Slave ****
+sync_slave_with_master;
+STOP SLAVE;
+source include/wait_for_slave_to_stop.inc;
+
+--echo **** On Master ****
+connection master;
+UPDATE t1 SET a = 2, b = 'master only' WHERE a = 1;
+DROP TRIGGER tr1;
+DROP TRIGGER tr2;
+INSERT INTO t1 VALUES (3,'master/slave');
+INSERT INTO t2 VALUES (3,'master/slave');
+INSERT INTO t3 VALUES (3,'master/slave');
+
+SELECT * FROM t1 ORDER BY a;
+SELECT * FROM t2 ORDER BY a;
+SELECT * FROM t3 ORDER BY a;
+
+save_master_pos;
+
+--echo *** On Slave ***
+connection slave;
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
+START SLAVE;
+source include/wait_for_slave_to_start.inc;
+sync_with_master;
+
+SELECT * FROM t1 ORDER BY a;
+SELECT * FROM t2 ORDER BY a;
+SELECT * FROM t3 ORDER BY a;
+
+connection master;
+DROP TABLE t1, t2, t3;
+sync_slave_with_master;
+
+--echo **** Case 2: Row binlog format and transactional tables ****
+
+# Create the transaction and try to skip some
+# queries from one.
+
+--echo *** On Master ***
+connection master;
+CREATE TABLE t4 (a INT, b VARCHAR(20)) ENGINE=innodb;
+CREATE TABLE t5 (a INT, b VARCHAR(20)) ENGINE=innodb;
+CREATE TABLE t6 (a INT, b VARCHAR(20)) ENGINE=innodb;
+
+--echo **** On Slave ****
+sync_slave_with_master;
+STOP SLAVE;
+source include/wait_for_slave_to_stop.inc;
+
+--echo *** On Master ***
+connection master;
+BEGIN;
+INSERT INTO t4 VALUES (2, 'master only');
+INSERT INTO t5 VALUES (2, 'master only');
+INSERT INTO t6 VALUES (2, 'master only');
+COMMIT;
+
+BEGIN;
+INSERT INTO t4 VALUES (3, 'master/slave');
+INSERT INTO t5 VALUES (3, 'master/slave');
+INSERT INTO t6 VALUES (3, 'master/slave');
+COMMIT;
+
+SELECT * FROM t4 ORDER BY a;
+SELECT * FROM t5 ORDER BY a;
+SELECT * FROM t6 ORDER BY a;
+
+save_master_pos;
+
+--echo *** On Slave ***
+connection slave;
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
+START SLAVE;
+source include/wait_for_slave_to_start.inc;
+sync_with_master;
+
+SELECT * FROM t4 ORDER BY a;
+SELECT * FROM t5 ORDER BY a;
+SELECT * FROM t6 ORDER BY a;
+
+# Test skipping two groups
+
+--echo **** On Slave ****
+connection slave;
+STOP SLAVE;
+source include/wait_for_slave_to_stop.inc;
+
+--echo *** On Master ***
+connection master;
+BEGIN;
+INSERT INTO t4 VALUES (6, 'master only');
+INSERT INTO t5 VALUES (6, 'master only');
+INSERT INTO t6 VALUES (6, 'master only');
+COMMIT;
+
+BEGIN;
+INSERT INTO t4 VALUES (7, 'master only');
+INSERT INTO t5 VALUES (7, 'master only');
+INSERT INTO t6 VALUES (7, 'master only');
+COMMIT;
+
+SELECT * FROM t4 ORDER BY a;
+SELECT * FROM t5 ORDER BY a;
+SELECT * FROM t6 ORDER BY a;
+
+save_master_pos;
+
+--echo *** On Slave ***
+connection slave;
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=10;
+START SLAVE;
+source include/wait_for_slave_to_start.inc;
+sync_with_master;
+
+SELECT * FROM t4 ORDER BY a;
+SELECT * FROM t5 ORDER BY a;
+SELECT * FROM t6 ORDER BY a;
+
+#
+# And the same, but with autocommit = 0
+#
+connection slave;
+STOP SLAVE;
+source include/wait_for_slave_to_stop.inc;
+
+connection master;
+SET AUTOCOMMIT=0;
+
+INSERT INTO t4 VALUES (4, 'master only');
+INSERT INTO t5 VALUES (4, 'master only');
+INSERT INTO t6 VALUES (4, 'master only');
+COMMIT;
+
+INSERT INTO t4 VALUES (5, 'master/slave');
+INSERT INTO t5 VALUES (5, 'master/slave');
+INSERT INTO t6 VALUES (5, 'master/slave');
+COMMIT;
+
+SELECT * FROM t4 ORDER BY a;
+SELECT * FROM t5 ORDER BY a;
+SELECT * FROM t6 ORDER BY a;
+
+save_master_pos;
+
+--echo *** On Slave ***
+connection slave;
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
+START SLAVE;
+source include/wait_for_slave_to_start.inc;
+sync_with_master;
+
+SELECT * FROM t4 ORDER BY a;
+SELECT * FROM t5 ORDER BY a;
+SELECT * FROM t6 ORDER BY a;
+
+connection master;
+DROP TABLE t4, t5, t6;
+sync_slave_with_master;
+
+--echo **** Case 3: Statement logging format and LOAD DATA with non-transactional table ****
+
+# LOAD DATA creates two events in binary log for statement binlog format.
+# Try to skip the first.
+
+--echo *** On Master ***
+connection master;
+CREATE TABLE t10 (a INT, b VARCHAR(20)) ENGINE=myisam;
+
+--echo *** On Slave ***
+sync_slave_with_master;
+STOP SLAVE;
+source include/wait_for_slave_to_stop.inc;
+
+--echo *** On Master ***
+connection master;
+SET SESSION BINLOG_FORMAT=STATEMENT;
+exec cp ./suite/rpl/data/rpl_bug28618.dat $MYSQLTEST_VARDIR/tmp/;
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/rpl_bug28618.dat' INTO TABLE t10 FIELDS TERMINATED BY '|';
+remove_file $MYSQLTEST_VARDIR/tmp/rpl_bug28618.dat;
+
+SELECT * FROM t10 ORDER BY a;
+
+save_master_pos;
+
+--echo *** On Slave ***
+connection slave;
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
+START SLAVE;
+source include/wait_for_slave_to_start.inc;
+sync_with_master;
+
+SELECT * FROM t10 ORDER BY a;
+
+connection master;
+DROP TABLE t10;
+sync_slave_with_master;
+
diff -Nrup a/mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result b/mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result
--- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result	2007-08-16 17:26:29 +02:00
+++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_extraCol.result	2007-10-19 14:18:31 +02:00
@@ -707,7 +707,7 @@ Last_IO_Errno	#
 Last_IO_Error	#
 Last_SQL_Errno	1060
 Last_SQL_Error	Error 'Duplicate column name 'c6'' on query. Default database: 'test'. Query: 'ALTER TABLE t15 ADD COLUMN c6 INT AFTER c5'
-SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2;
+SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
 START SLAVE;
 *** Try to insert in master ****
 INSERT INTO t15 () VALUES(5,2.00,'Replication Testing',@b1,'Buda',2);
diff -Nrup a/sql/log_event.cc b/sql/log_event.cc
--- a/sql/log_event.cc	2007-09-24 11:45:56 +02:00
+++ b/sql/log_event.cc	2007-10-19 14:18:33 +02:00
@@ -570,7 +570,8 @@ Log_event::do_shall_skip(Relay_log_info 
                       (ulong) server_id, (ulong) ::server_id,
                       rli->replicate_same_server_id,
                       rli->slave_skip_counter));
-  if (server_id == ::server_id && !rli->replicate_same_server_id)
+  if (server_id == ::server_id && !rli->replicate_same_server_id ||
+      rli->slave_skip_counter == 1 && rli->is_in_group())
     return EVENT_SKIP_IGNORE;
   else if (rli->slave_skip_counter > 0)
     return EVENT_SKIP_COUNT;
@@ -1227,6 +1228,16 @@ void Log_event::print_timestamp(IO_CACHE
 #endif /* MYSQL_CLIENT */
 
 
+#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+inline Log_event::enum_skip_reason
+Log_event::continue_group(Relay_log_info *rli)
+{
+  if (rli->slave_skip_counter == 1)
+    return Log_event::EVENT_SKIP_IGNORE;
+  return Log_event::do_shall_skip(rli);
+}
+#endif
+
 /**************************************************************************
 	Query_log_event methods
 **************************************************************************/
@@ -2235,6 +2246,30 @@ int Query_log_event::do_update_pos(Relay
 }
 
 
+Log_event::enum_skip_reason
+Query_log_event::do_shall_skip(Relay_log_info *rli)
+{
+  DBUG_ENTER("Query_log_event::do_shall_skip");
+  DBUG_PRINT("debug", ("query: %s; q_len: %d", query, q_len));
+  DBUG_ASSERT(query && q_len > 0);
+
+  if (rli->slave_skip_counter > 0)
+  {
+    if (strcmp("BEGIN", query) == 0)
+    {
+      thd->options|= OPTION_BEGIN;
+      DBUG_RETURN(Log_event::continue_group(rli));
+    }
+
+    if (strcmp("COMMIT", query) == 0 || strcmp("ROLLBACK", query) == 0)
+    {
+      thd->options&= ~OPTION_BEGIN;
+      DBUG_RETURN(Log_event::EVENT_SKIP_COUNT);
+    }
+  }
+  DBUG_RETURN(Log_event::do_shall_skip(rli));
+}
+
 #endif
 
 
@@ -3871,10 +3906,7 @@ Intvar_log_event::do_shall_skip(Relay_lo
     that we do not change the value of the slave skip counter since it
     will be decreased by the following insert event.
   */
-  if (rli->slave_skip_counter == 1)
-    return Log_event::EVENT_SKIP_IGNORE;
-  else
-    return Log_event::do_shall_skip(rli);
+  return continue_group(rli);
 }
 
 #endif
@@ -3970,10 +4002,7 @@ Rand_log_event::do_shall_skip(Relay_log_
     that we do not change the value of the slave skip counter since it
     will be decreased by the following insert event.
   */
-  if (rli->slave_skip_counter == 1)
-    return Log_event::EVENT_SKIP_IGNORE;
-  else
-    return Log_event::do_shall_skip(rli);
+  return continue_group(rli);
 }
 
 #endif /* !MYSQL_CLIENT */
@@ -4049,6 +4078,17 @@ int Xid_log_event::do_apply_event(Relay_
                     "COMMIT /* implicit, from Xid_log_event */");
   return end_trans(thd, COMMIT);
 }
+
+Log_event::enum_skip_reason
+Xid_log_event::do_shall_skip(Relay_log_info *rli)
+{
+  DBUG_ENTER("Xid_log_event::do_shall_skip");
+  if (rli->slave_skip_counter > 0) {
+    thd->options&= ~OPTION_BEGIN;
+    DBUG_RETURN(Log_event::EVENT_SKIP_COUNT);
+  }
+  DBUG_RETURN(Log_event::do_shall_skip(rli));
+}
 #endif /* !MYSQL_CLIENT */
 
 
@@ -4427,10 +4467,7 @@ User_var_log_event::do_shall_skip(Relay_
     that we do not change the value of the slave skip counter since it
     will be decreased by the following insert event.
   */
-  if (rli->slave_skip_counter == 1)
-    return Log_event::EVENT_SKIP_IGNORE;
-  else
-    return Log_event::do_shall_skip(rli);
+  return continue_group(rli);
 }
 #endif /* !MYSQL_CLIENT */
 
@@ -5366,6 +5403,19 @@ int Begin_load_query_log_event::get_crea
 #endif /* defined( HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
 
 
+#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+Log_event::enum_skip_reason
+Begin_load_query_log_event::do_shall_skip(Relay_log_info *rli)
+{
+  /*
+    If the slave skip counter is 1, then we should not start executing
+    on the next event.
+  */
+  return continue_group(rli);
+}
+#endif
+
+
 /**************************************************************************
 	Execute_load_query_log_event methods
 **************************************************************************/
@@ -6870,10 +6920,7 @@ Table_map_log_event::do_shall_skip(Relay
     If the slave skip counter is 1, then we should not start executing
     on the next event.
   */
-  if (rli->slave_skip_counter == 1)
-    return Log_event::EVENT_SKIP_IGNORE;
-  else
-    return Log_event::do_shall_skip(rli);
+  return continue_group(rli);
 }
 
 int Table_map_log_event::do_update_pos(Relay_log_info *rli)
diff -Nrup a/sql/log_event.h b/sql/log_event.h
--- a/sql/log_event.h	2007-09-10 13:59:35 +02:00
+++ b/sql/log_event.h	2007-10-19 14:18:33 +02:00
@@ -871,6 +871,25 @@ public:
 protected:
 
   /**
+     Helper function to ignore an event w.r.t. the slave skip counter.
+
+     This function can be used inside do_shall_skip() for functions
+     that cannot end a group. If the slave skip counter is 1 when
+     seeing such an event, the event shall be ignored, the counter
+     left intact, and processing continue with the next event.
+
+     A typical usage is:
+     @code
+     enum_skip_reason do_shall_skip(Relay_log_info *rli) {
+       return continue_group(rli);
+     }
+     @endcode
+
+     @return Skip reason
+   */
+  enum_skip_reason continue_group(Relay_log_info *rli);
+
+  /**
     Primitive to apply an event to the database.
 
     This is where the change to the database is made.
@@ -1086,6 +1105,7 @@ public:
 
 public:        /* !!! Public in this patch to allow old usage */
 #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
   virtual int do_apply_event(Relay_log_info const *rli);
   virtual int do_update_pos(Relay_log_info *rli);
 
@@ -1559,6 +1579,7 @@ class Xid_log_event: public Log_event
 private:
 #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
   virtual int do_apply_event(Relay_log_info const *rli);
+  enum_skip_reason do_shall_skip(Relay_log_info *rli);
 #endif
 };
 
@@ -1937,6 +1958,10 @@ public:
                              *description_event);
   ~Begin_load_query_log_event() {}
   Log_event_type get_type_code() { return BEGIN_LOAD_QUERY_EVENT; }
+private:
+#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+  virtual enum_skip_reason do_shall_skip(Relay_log_info *rli);
+#endif
 };
 
 
diff -Nrup a/sql/rpl_rli.h b/sql/rpl_rli.h
--- a/sql/rpl_rli.h	2007-08-17 13:22:25 +02:00
+++ b/sql/rpl_rli.h	2007-10-19 14:18:33 +02:00
@@ -366,6 +366,18 @@ public:
   }
 
   /**
+     Get the value of a replication state flag.
+
+     @param flag Flag to get value of
+
+     @return @c true if the flag was set, @c false otherwise.
+   */
+  bool get_flag(enum_state_flag flag)
+  {
+    return m_flags & (1UL << flag);
+  }
+
+  /**
      Clear the value of a replication state flag.
 
      @param flag Flag to clear
diff -Nrup a/sql/slave.cc b/sql/slave.cc
--- a/sql/slave.cc	2007-09-17 12:38:14 +02:00
+++ b/sql/slave.cc	2007-10-19 14:18:34 +02:00
@@ -1853,10 +1853,13 @@ static int exec_relay_log_event(THD* thd
       // EVENT_SKIP_NOT,
       "not skipped",
       // EVENT_SKIP_IGNORE,
-      "skipped because event originated from this server",
+      "skipped because event should be ignored",
       // EVENT_SKIP_COUNT
       "skipped because event skip counter was non-zero"
     };
+    DBUG_PRINT("info", ("OPTION_BEGIN: %d; IN_STMT: %d",
+                        thd->options & OPTION_BEGIN ? 1 : 0,
+                        rli->get_flag(Relay_log_info::IN_STMT)));
     DBUG_PRINT("skip_event", ("%s event was %s",
                               ev->get_type_str(), explain[reason]));
 #endif
Thread
bk commit into 5.1 tree (mats:1.2578) BUG#28618Mats Kindahl19 Oct