MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Sven Sandberg Date:July 3 2008 3:37pm
Subject:bzr commit into mysql-5.1 branch (sven:2682) Bug#37718
View as plain text  
#At file:///home/sven/bzr/b37718-rpl_stm_mystery22/5.1-bugteam/

 2682 Sven Sandberg	2008-07-03
      BUG#37718: rpl.rpl_stm_mystery22 failed on pushbuild
      rpl_stm_mystery22 failed because 'START SLAVE' was not
      followed by 'source include/wait_for_slave_to_start.inc'.
      Fixed by adding include/start_slave.inc and sourcing that
      file.
      Also commented the test and removed unnecessary code.
      Also, the test contains no mystery and is not related to
      the number 22, so it has been renamed to rpl_conflicts.
removed:
  mysql-test/suite/rpl/t/rpl_row_mystery22.test
added:
  mysql-test/include/start_slave.inc
  mysql-test/include/stop_slave.inc
  mysql-test/suite/rpl/t/rpl_row_conflicts.test
  mysql-test/suite/rpl/t/rpl_stm_conflicts.test
renamed:
  mysql-test/suite/rpl/r/rpl_row_mystery22.result => mysql-test/suite/rpl/r/rpl_row_conflicts.result
  mysql-test/suite/rpl/r/rpl_stm_mystery22.result => mysql-test/suite/rpl/r/rpl_stm_conflicts.result
  mysql-test/suite/rpl/t/rpl_stm_mystery22.test => mysql-test/extra/rpl_tests/rpl_conflicts.test
modified:
  mysql-test/suite/rpl/r/rpl_row_conflicts.result
  mysql-test/suite/rpl/r/rpl_stm_conflicts.result
  mysql-test/extra/rpl_tests/rpl_conflicts.test

per-file messages:
  mysql-test/extra/rpl_tests/rpl_conflicts.test
     - Factored out rpl_stm_mystery22.test and rpl_row_mystery22.test into one file.
     - Renamed the file to rpl_conflicts.test
     - Added comments explaining what the test does and how it does that.
     - Fixed BUG#37718: rpl.rpl_stm_mystery22 failed on pushbuild
     - Removed unnecessary 'create table t2 ; drop table t2'
  mysql-test/include/start_slave.inc
    This file should be used instead of 'START SLAVE', to ensure the slave is running.
    We used to have many bugs caused by the test case author forgetting to
    do source include/wait_for_slave_to_start.inc after START SLAVE. This
    is an attempt to make it easier to write test cases without doing
    that mistake.
  mysql-test/include/stop_slave.inc
    This file should be used instead of 'STOP SLAVE', to ensure the slave is stopped.
    We used to have many bugs caused by the test case author forgetting to
    do source include/wait_for_slave_to_stop.inc after STOP SLAVE. This
    is an attempt to make it easier to write test cases without doing
    that mistake.
  mysql-test/suite/rpl/r/rpl_row_conflicts.result
    Updated and renamed result file.
  mysql-test/suite/rpl/r/rpl_stm_conflicts.result
    Updated and renamed result file.
  mysql-test/suite/rpl/t/rpl_row_conflicts.test
    This file replaces the old rpl_row_mystery22.test
  mysql-test/suite/rpl/t/rpl_row_mystery22.test
    This file has been replaced by rpl_row_conflicts.test
  mysql-test/suite/rpl/t/rpl_stm_conflicts.test
    This file replaces the old rpl_stm_mystery22.test
=== renamed file 'mysql-test/suite/rpl/t/rpl_stm_mystery22.test' => 'mysql-test/extra/rpl_tests/rpl_conflicts.test'
--- a/mysql-test/suite/rpl/t/rpl_stm_mystery22.test	2007-10-10 16:10:54 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_conflicts.test	2008-07-03 15:37:29 +0000
@@ -1,66 +1,139 @@
-################################
-# Change Author: JBM
-# Change Date: 2006-01-12
-# Change: Added back have stm binlog
-# and added requirments comments
-################################
-# test case to make slave thread get ahead by 22 bytes
-################################
-#REQUIREMENT: If there is a faked slave duplicate key insert 
-#error and the slave is restarted, the replication should 
-#proceed in a correct way.
-################################
-#REQUIREMENT: If there is a faked slave non-existing record 
-#delete error and the slave is restarted, then the replication 
-#should proceed in a correct way.
-#################################
+# ==== Purpose ====
+#
+# Test that slave behaves well in some conflict situations.  The
+# following are tested:
+#
+# - The slave SQL thread sees an 'INSERT' of a row with a key that
+#   already exists in the table.  In this case, the slave behavior
+#   depends on the binlog format and the value of @@slave_exec_mode on
+#   the slave:
+#
+#    - If the query is written in statement mode, or
+#      @@slave_exec_mode!=IDEMPOTENT, the slave should stop. If the
+#      already existing row is removed from the slave, and the slave
+#      started again, it should proceed normally.
+#
+#    - If the query is written in row mode, and
+#      @@slave_exec_mode=IDEMPOTENT, the slave should not try to
+#      insert the row and proceed normally.
+#
+# - The slave SQL thread sees a 'DELETE' of a row that does not exist.
+#   In this case, the slave should ignore the event and proceed
+#   normally.
+#
+# This test was previously named rpl_stm_mystery22/rpl_row_mystery22.
+#
+#
+# ==== Method ====
+#
+# Create a table on master and slave, insert a row on slave, and
+# insert the same row on master.
+#
+# Create a table on master and slave, insert a row on master with
+# binlogging turned off, and remove the row on master with binlogging
+# turned on.
+#
+#
+# ==== Related bugs ====
+#
+# BUG#31552: Replication breaks when deleting rows from out-of-sync table without PK
+# BUG#31609: Not all RBR slave errors reported as errors
+#
+#
+# ==== Usage ====
+#
+# This file assumes the following:
+#
+# - The test language variable $expect_slave_error_on_duplicate_key is
+#   set to 1 if the slave is expected to stop on duplicate key errors
+#   (i.e., if the binlog is in statement mode or
+#   @@global.slave_exec_mode=STRICT). It is set to 0 otherwise.
+#
+# - Replication has been initialized by include/master-slave.inc
 
--- source include/have_binlog_format_mixed_or_statement.inc
--- source include/master-slave.inc
 
-# first, cause a duplicate key problem on the slave
-create table t1(n int auto_increment primary key, s char(10));
+--echo ==== Initialize ====
+
+--echo [on master]
+connection master;
+CREATE TABLE t1(n INT AUTO_INCREMENT PRIMARY KEY, s CHAR(10));
+--echo [on slave]
 sync_slave_with_master;
-insert into t1 values (2,'old');
+
+
+--echo ==== Test: SQL thread sees 'INSERT' of existing key ====
+
+--echo ---- Prepare slave so that it will get duplicate key error ----
+# This row will be in the way of the row inserted by master.
+INSERT INTO t1 VALUES (2,'old');
+
+--echo ---- Insert rows on master ----
+--echo [on master]
 connection master;
-insert into t1 values(NULL,'new');
-insert into t1 values(NULL,'new');
+# Insert the same row on master
+INSERT INTO t1 VALUES(NULL,'new');
+INSERT INTO t1 VALUES(NULL,'new');
 save_master_pos;
+SELECT * FROM t1 ORDER BY n;
+
+--echo [on slave]
 connection slave;
-# wait until the slave tries to run the query, fails and aborts slave thread
-source include/wait_for_slave_sql_error.inc;
-select * from t1 order by n;
-delete from t1 where n = 2;
---disable_warnings
-start slave;
---enable_warnings
+
+# If we are in statement mode or if slave_exec_mode=STRICT, we now
+# expect to see an error on the slave.  Otherwise, we expect that the
+# duplicate row is ignored by the slave and replication continues.
+if ($expect_slave_error_on_duplicate_key) {
+  --echo ---- Wait until slave stops with an error ----
+  # wait until the slave tries to run the query, fails and aborts slave thread
+  source include/wait_for_slave_sql_error.inc;
+  let $err= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
+  --echo Last_SQL_Error = $err (expected duplicate key error)
+  SELECT * FROM t1 ORDER BY n;
+
+  --echo ---- Resolve the problem on the slave ----
+  DELETE FROM t1 WHERE n = 2;
+  source include/start_slave.inc;
+}
+
+--echo ---- Sync slave and verify that there is no error ----
 sync_with_master;
-#now the buggy slave would be confused on the offset but it can replicate
-#in order to make it break, we need to stop/start the slave one more time
-stop slave;
+let $err= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
+--echo Last_SQL_Error = '$err' (expected no error)
+SELECT * FROM t1 ORDER BY n;
+
+
+--echo ==== Test: SQL thread sees 'DELETE' of non-existing row ====
+
+--echo ---- On master, insert two rows, the second with binlogging off ----
+--echo [on master]
 connection master;
-# to be able to really confuse the slave, we need some non-auto-increment
-# events in the log
-create table t2(n int);
-drop table t2;
-insert into t1 values(NULL,'new');
-# what happens when we delete a row which does not exist on slave?
-set sql_log_bin=0;
-insert into t1 values(NULL,'new');
-set sql_log_bin=1;
-delete from t1 where n=4;
+DELETE FROM t1;
+INSERT INTO t1 VALUES(NULL,'new');
+SET sql_log_bin=0;
+INSERT INTO t1 VALUES(NULL,'new');
+SET sql_log_bin=1;
+
+--echo ---- On master, remove the row that does not exist on slave ----
+DELETE FROM t1 WHERE n=2;
+SELECT * FROM t1 ORDER BY n;
 save_master_pos;
+
+--echo ---- On slave, verify that no error happened ----
+--echo [on slave]
 connection slave;
---disable_warnings
-start slave;
---enable_warnings
-#now the truth comes out - if the slave is buggy, it will never sync because
-#the slave thread is not able to read events
+# The slave should sync ok, and SHOW SLAVE STATUS should give no
+# error.
 sync_with_master;
-select * from t1 order by n;
-#clean up
+let $err= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
+--echo Last_SQL_Error = $err
+SELECT * FROM t1 ORDER BY n;
+
+
+--echo ==== Clean up ====
+
+--echo [on master]
 connection master;
-drop table t1;
-sync_slave_with_master;
+DROP TABLE t1;
 
-# End of 4.1 tests
+--echo [on slave]
+sync_slave_with_master;

=== added file 'mysql-test/include/start_slave.inc'
--- a/mysql-test/include/start_slave.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/start_slave.inc	2008-07-03 15:37:29 +0000
@@ -0,0 +1,11 @@
+# ==== Purpose ====
+#
+# Starts the slave synchronously, i.e., waits until the slave has
+# started after calling START SLAVE.
+#
+# ==== Usage ====
+#
+# source include/start_slave.inc;
+
+START SLAVE;
+source include/wait_for_slave_to_start.inc;

=== added file 'mysql-test/include/stop_slave.inc'
--- a/mysql-test/include/stop_slave.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/stop_slave.inc	2008-07-03 15:37:29 +0000
@@ -0,0 +1,11 @@
+# ==== Purpose ====
+#
+# Stops the slave synchronously, i.e., waits until the slave has
+# stopped after calling STOP SLAVE.
+#
+# ==== Usage ====
+#
+# source include/stop_slave.inc;
+
+STOP SLAVE;
+source include/wait_for_slave_to_stop.inc;

=== renamed file 'mysql-test/suite/rpl/r/rpl_row_mystery22.result' => 'mysql-test/suite/rpl/r/rpl_row_conflicts.result'
--- a/mysql-test/suite/rpl/r/rpl_row_mystery22.result	2007-12-12 10:14:59 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_conflicts.result	2008-07-03 15:37:29 +0000
@@ -4,29 +4,108 @@ reset master;
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
-create table t1(n int auto_increment primary key, s char(10));
+######## Run with slave_exec_mode=STRICT ########
+==== Initialize ====
+[on master]
+CREATE TABLE t1(n INT AUTO_INCREMENT PRIMARY KEY, s CHAR(10));
+[on slave]
+==== Test: SQL thread sees 'INSERT' of existing key ====
+---- Prepare slave so that it will get duplicate key error ----
+INSERT INTO t1 VALUES (2,'old');
+---- Insert rows on master ----
+[on master]
+INSERT INTO t1 VALUES(NULL,'new');
+INSERT INTO t1 VALUES(NULL,'new');
+SELECT * FROM t1 ORDER BY n;
+n	s
+1	new
+2	new
+[on slave]
+---- Wait until slave stops with an error ----
+Last_SQL_Error = Could not execute Write_rows event on table test.t1; Duplicate entry '2' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log master-bin.000001, end_log_pos 599 (expected duplicate key error)
+SELECT * FROM t1 ORDER BY n;
+n	s
+1	new
+2	old
+---- Resolve the problem on the slave ----
+DELETE FROM t1 WHERE n = 2;
+START SLAVE;
+---- Sync slave and verify that there is no error ----
+Last_SQL_Error = '' (expected no error)
+SELECT * FROM t1 ORDER BY n;
+n	s
+1	new
+2	new
+==== Test: SQL thread sees 'DELETE' of non-existing row ====
+---- On master, insert two rows, the second with binlogging off ----
+[on master]
+DELETE FROM t1;
+INSERT INTO t1 VALUES(NULL,'new');
+SET sql_log_bin=0;
+INSERT INTO t1 VALUES(NULL,'new');
+SET sql_log_bin=1;
+---- On master, remove the row that does not exist on slave ----
+DELETE FROM t1 WHERE n=2;
+SELECT * FROM t1 ORDER BY n;
+n	s
+3	new
+4	new
+---- On slave, verify that no error happened ----
+[on slave]
+Last_SQL_Error = 
+SELECT * FROM t1 ORDER BY n;
+n	s
+3	new
+==== Clean up ====
+[on master]
+DROP TABLE t1;
+[on slave]
+######## Run with slave_exec_mode=IDEMPOTENT ########
 set @@global.slave_exec_mode= 'IDEMPOTENT';
-insert into t1 values (2,'old');
-insert into t1 values(NULL,'new');
-insert into t1 values(NULL,'new');
-select * from t1 order by n;
+==== Initialize ====
+[on master]
+CREATE TABLE t1(n INT AUTO_INCREMENT PRIMARY KEY, s CHAR(10));
+[on slave]
+==== Test: SQL thread sees 'INSERT' of existing key ====
+---- Prepare slave so that it will get duplicate key error ----
+INSERT INTO t1 VALUES (2,'old');
+---- Insert rows on master ----
+[on master]
+INSERT INTO t1 VALUES(NULL,'new');
+INSERT INTO t1 VALUES(NULL,'new');
+SELECT * FROM t1 ORDER BY n;
 n	s
 1	new
 2	new
-delete from t1 where n = 2;
-start slave;
-stop slave;
-create table t2(n int);
-drop table t2;
-insert into t1 values(NULL,'new');
-set sql_log_bin=0;
-insert into t1 values(NULL,'new');
-set sql_log_bin=1;
-delete from t1 where n=4;
-start slave;
-select * from t1 order by n;
+[on slave]
+---- Sync slave and verify that there is no error ----
+Last_SQL_Error = '' (expected no error)
+SELECT * FROM t1 ORDER BY n;
 n	s
 1	new
+2	new
+==== Test: SQL thread sees 'DELETE' of non-existing row ====
+---- On master, insert two rows, the second with binlogging off ----
+[on master]
+DELETE FROM t1;
+INSERT INTO t1 VALUES(NULL,'new');
+SET sql_log_bin=0;
+INSERT INTO t1 VALUES(NULL,'new');
+SET sql_log_bin=1;
+---- On master, remove the row that does not exist on slave ----
+DELETE FROM t1 WHERE n=2;
+SELECT * FROM t1 ORDER BY n;
+n	s
+3	new
+4	new
+---- On slave, verify that no error happened ----
+[on slave]
+Last_SQL_Error = 
+SELECT * FROM t1 ORDER BY n;
+n	s
 3	new
-drop table t1;
+==== Clean up ====
+[on master]
+DROP TABLE t1;
+[on slave]
 set @@global.slave_exec_mode= default;

=== renamed file 'mysql-test/suite/rpl/r/rpl_stm_mystery22.result' => 'mysql-test/suite/rpl/r/rpl_stm_conflicts.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_mystery22.result	2007-06-27 12:28:02 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_conflicts.result	2008-07-03 15:37:29 +0000
@@ -4,28 +4,58 @@ reset master;
 reset slave;
 drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
 start slave;
-create table t1(n int auto_increment primary key, s char(10));
-insert into t1 values (2,'old');
-insert into t1 values(NULL,'new');
-insert into t1 values(NULL,'new');
-select * from t1 order by n;
+==== Initialize ====
+[on master]
+CREATE TABLE t1(n INT AUTO_INCREMENT PRIMARY KEY, s CHAR(10));
+[on slave]
+==== Test: SQL thread sees 'INSERT' of existing key ====
+---- Prepare slave so that it will get duplicate key error ----
+INSERT INTO t1 VALUES (2,'old');
+---- Insert rows on master ----
+[on master]
+INSERT INTO t1 VALUES(NULL,'new');
+INSERT INTO t1 VALUES(NULL,'new');
+SELECT * FROM t1 ORDER BY n;
+n	s
+1	new
+2	new
+[on slave]
+---- Wait until slave stops with an error ----
+Last_SQL_Error = Error 'Duplicate entry '2' for key 'PRIMARY'' on query. Default database: 'test'. Query: 'INSERT INTO t1 VALUES(NULL,'new')' (expected duplicate key error)
+SELECT * FROM t1 ORDER BY n;
 n	s
 1	new
 2	old
-delete from t1 where n = 2;
-start slave;
-stop slave;
-create table t2(n int);
-drop table t2;
-insert into t1 values(NULL,'new');
-set sql_log_bin=0;
-insert into t1 values(NULL,'new');
-set sql_log_bin=1;
-delete from t1 where n=4;
-start slave;
-select * from t1 order by n;
+---- Resolve the problem on the slave ----
+DELETE FROM t1 WHERE n = 2;
+START SLAVE;
+---- Sync slave and verify that there is no error ----
+Last_SQL_Error = '' (expected no error)
+SELECT * FROM t1 ORDER BY n;
 n	s
 1	new
 2	new
+==== Test: SQL thread sees 'DELETE' of non-existing row ====
+---- On master, insert two rows, the second with binlogging off ----
+[on master]
+DELETE FROM t1;
+INSERT INTO t1 VALUES(NULL,'new');
+SET sql_log_bin=0;
+INSERT INTO t1 VALUES(NULL,'new');
+SET sql_log_bin=1;
+---- On master, remove the row that does not exist on slave ----
+DELETE FROM t1 WHERE n=2;
+SELECT * FROM t1 ORDER BY n;
+n	s
+3	new
+4	new
+---- On slave, verify that no error happened ----
+[on slave]
+Last_SQL_Error = 
+SELECT * FROM t1 ORDER BY n;
+n	s
 3	new
-drop table t1;
+==== Clean up ====
+[on master]
+DROP TABLE t1;
+[on slave]

=== added file 'mysql-test/suite/rpl/t/rpl_row_conflicts.test'
--- a/mysql-test/suite/rpl/t/rpl_row_conflicts.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_conflicts.test	2008-07-03 15:37:29 +0000
@@ -0,0 +1,28 @@
+# See the top of mysql-test/extra/rpl_tests/rpl_conflicts.test for
+# explanation of what this test does.
+#
+# This test file is for row mode. It runs the test twice, with
+# slave_exec_mode=STRICT and slave_exec_mode=IDEMPOTENT, respectively.
+
+source include/have_binlog_format_row.inc;
+source include/master-slave.inc;
+
+
+--echo ######## Run with slave_exec_mode=STRICT ########
+
+let $expect_slave_error_on_duplicate_key= 1;
+source extra/rpl_tests/rpl_conflicts.test;
+
+
+--echo ######## Run with slave_exec_mode=IDEMPOTENT ########
+connection slave;
+set @@global.slave_exec_mode= 'IDEMPOTENT';
+
+let $expect_slave_error_on_duplicate_key= 0;
+source extra/rpl_tests/rpl_conflicts.test;
+
+connection slave;
+set @@global.slave_exec_mode= default;
+
+
+source include/master-slave-end.inc;

=== removed file 'mysql-test/suite/rpl/t/rpl_row_mystery22.test'
--- a/mysql-test/suite/rpl/t/rpl_row_mystery22.test	2007-12-12 10:14:59 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_mystery22.test	1970-01-01 00:00:00 +0000
@@ -1,52 +0,0 @@
-# Originally taken from rpl_mystery22.test,
-# but this row-based-replication test has a totally different spirit:
-# slave will not stop because of dup key,
-# instead we test if it does overwrite the dup key
-# as expected.
--- source include/have_binlog_format_row.inc
--- source include/master-slave.inc
-
-# first, cause a duplicate key problem on the slave
-create table t1(n int auto_increment primary key, s char(10));
-sync_slave_with_master;
-
-# bug#31552/31609 idempotency is not default any longer
-# so that the declared in heading comments aim of the test
-# should be backed up with explicit setting of the slave mode
-set @@global.slave_exec_mode= 'IDEMPOTENT';
-
-insert into t1 values (2,'old');
-connection master;
-insert into t1 values(NULL,'new');
-insert into t1 values(NULL,'new');
-save_master_pos;
-connection slave;
-sync_with_master;
-select * from t1 order by n;
-delete from t1 where n = 2;
---disable_warnings
-start slave;
---enable_warnings
-sync_with_master;
-stop slave;
-connection master;
-create table t2(n int);
-drop table t2;
-insert into t1 values(NULL,'new');
-# what happens when we delete a row which does not exist on slave?
-set sql_log_bin=0;
-insert into t1 values(NULL,'new');
-set sql_log_bin=1;
-delete from t1 where n=4;
-save_master_pos;
-connection slave;
---disable_warnings
-start slave;
---enable_warnings
-sync_with_master;
-select * from t1 order by n;
-#clean up
-connection master;
-drop table t1;
-sync_slave_with_master;
-set @@global.slave_exec_mode= default;

=== added file 'mysql-test/suite/rpl/t/rpl_stm_conflicts.test'
--- a/mysql-test/suite/rpl/t/rpl_stm_conflicts.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_stm_conflicts.test	2008-07-03 15:37:29 +0000
@@ -0,0 +1,12 @@
+# See the top of mysql-test/extra/rpl_tests/rpl_conflicts.test for an
+# explanation of what is going on.
+#
+# This test file is for statement mode.
+
+source include/have_binlog_format_mixed_or_statement.inc;
+source include/master-slave.inc;
+
+let $expect_slave_error_on_duplicate_key= 1;
+source extra/rpl_tests/rpl_conflicts.test;
+
+source include/master-slave-end.inc;

Thread
bzr commit into mysql-5.1 branch (sven:2682) Bug#37718Sven Sandberg3 Jul