~mathiaz/ubuntu/lucid/mysql-dfsg-5.1/zap-bug-552053

« back to all changes in this revision

Viewing changes to mysql-test/extra/rpl_tests/rpl_conflicts.test

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug
  • Date: 2009-06-25 12:55:45 UTC
  • mfrom: (1.1.2 upstream) (0.1.3 experimental)
  • Revision ID: james.westby@ubuntu.com-20090625125545-m8ogs96zzsri74xe
Tags: 5.1.34-1ubuntu1
* Merge from debian experimental (and 5.0 from main), remaining changes:
  - debian/mysql-server-5.1.config:
    + ask for MySQL root password at priority high instead of medium so
      that the password prompt is seen on a default install. (LP: #319843)
    + don't ask for root password when upgrading from a 5.0 install.
  - debian/control:
    + Make libmysqlclient16-dev a transitional package depending on
      libmysqlclient-dev.
    + Make libmysqlclient-dev conflict with libmysqlclient15-dev.
    + Don't build mysql-server, mysql-client, mysql-common and
      libmysqlclient15-dev binary packages since they're still provided
      by mysql-dfsg-5.0.
    + Make mysql-{client,server}-5.1 packages conflict and
      replace mysql-{client,server}-5.0, but not provide
      mysql-{client,server}.
    + Depend on a specific version of mysql-common rather than the src
      version of mysql-dfsg-5.1 since mysql-common is currently part of
      mysql-dfsg-5.0.
    + Lower mailx from a Recommends to a Suggests to avoid pulling in
      a full MTA on all installs of mysql-server. (LP: #259477)
  - debian/rules:
    + added -fno-strict-aliasing to CFLAGS to get around mysql testsuite
      build failures.
    + install mysql-test and sql-bench to /usr/share/mysql/ rather than
      /usr/.
  - debian/additions/debian-start.inc.sh: support ANSI mode (LP: #310211)
  - Add AppArmor profile:
    - debian/apparmor-profile: apparmor profile.
    - debian/rules, debian/mysql-server-5.0.files: install apparmor profile.
    - debian/mysql-server-5.0.dirs: add etc/apparmor.d/force-complain
    - debian/mysql-server-5.0.postrm: remove symlink in force-complain/ on
      purge.
    - debian/mysql-server-5.1.README.Debian: add apparmor documentation.
    - debian/additions/my.cnf: Add warning about apparmor. (LP: #201799)
    - debian/mysql-server-5.1.postinst: reload apparmor profiles.
  - debian/additions/my.cnf: remove language option. Error message files are
    located in a different directory in MySQL 5.0. Setting the language
    option to use /usr/share/mysql/english breaks 5.0. Both 5.0 and 5.1
    use a default value that works. (LP: #316974)
  - debian/mysql-server-5.1.mysql.init:
    + Clearly indicate that we do not support running multiple instances
      of mysqld by duplicating the init script.
      (closes: #314785, #324834, #435165, #444216)
    + Properly parameterize all existing references to the mysql config
      file (/etc/mysql/my.cnf).
  - debian/mysql-server-5.0.postinst: Clear out the second password
    when setting up mysql. (LP: #344816)
  - mysql-server-core-5.1 package for files needed by Akonadi:
    + debian/control: create mysql-server-core-5.1 package.
    + debian/mysql-server-core-5.1.files, debian/mysql-server-5.1.files:
      move core mysqld files to mysql-server-core-5.1 package.
  - Don't package sql-bench and mysql-test file.
* Dropped changes:
  - debian/patches/92_ssl_test_cert.dpatch: certificate expiration in
    test suite (LP: #323755). Included upstream.
* Dropped from 5.0:
  - apparmor profile:
    - debian/control: Recommends apparmor >= 2.1+1075-0ubuntu6. All version
      of apparmor-profile (>hardy) are higher than this version.
    - debian/mysql-server-5.0.preinst: create symlink for force-complain/
      on pre-feisty upgrades, upgrades where apparmor-profiles profile is
      unchanged (ie non-enforcing) and upgrades where the profile
      doesn't exist. Support for pre-hardy upgrades is no longer needed.
* debian/mysql-server-5.1.postinst: fix debian-sys-maint user creation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# ==== Purpose ====
 
2
#
 
3
# Test that slave behaves well in some conflict situations.  The
 
4
# following are tested:
 
5
#
 
6
# - The slave SQL thread sees an 'INSERT' of a row with a key that
 
7
#   already exists in the table;
 
8
#
 
9
# - The slave SQL thread sees a 'DELETE' of a row that does not
 
10
#   exist in the table.
 
11
#
 
12
# In statement-logging mode, the first conflict type causes the slave
 
13
# to stop with an error and the second conflict is ignored.
 
14
#
 
15
# In row-logging mode, the slave behavior depends the value of
 
16
# @@slave_exec_mode on the slave: if @@slave_exec_mode is IDEMPOTENT,
 
17
# the slave should ignore the conflicting statement and continue
 
18
# normally.  If @@slave_exec_mode is STRICT, the slave should stop
 
19
# with an error.
 
20
#
 
21
# This test was previously named rpl_stm_mystery22/rpl_row_mystery22.
 
22
#
 
23
#
 
24
# ==== Method ====
 
25
#
 
26
# Create a table on master and slave, insert a row on slave, and
 
27
# insert the same row on master.
 
28
#
 
29
# Create a table on master and slave, insert a row on master with
 
30
# binlogging turned off, and remove the row on master with binlogging
 
31
# turned on.
 
32
#
 
33
#
 
34
# ==== Related bugs ====
 
35
#
 
36
# BUG#31552: Replication breaks when deleting rows from out-of-sync table without PK
 
37
# BUG#31609: Not all RBR slave errors reported as errors
 
38
#
 
39
# Bug in this test case:
 
40
# BUG#37718: rpl.rpl_stm_mystery22 fails sporadically on pushbuild
 
41
#
 
42
#
 
43
# ==== Usage ====
 
44
#
 
45
# This file assumes the following:
 
46
#
 
47
# - The test language variable $slave_is_idempotent is set to 1 if the
 
48
#   slave is expected to stop on duplicate key errors (i.e., if the
 
49
#   binlog is in statement mode or
 
50
#   @@global.slave_exec_mode=STRICT). It is set to 0 otherwise.
 
51
#
 
52
# - Replication has been initialized by include/master-slave.inc
 
53
#
 
54
# - The test adds a suppression for the following warning:
 
55
#    Slave: Can't find record in 't1' Error_code: 1032
 
56
 
 
57
 
 
58
--echo ==== Initialize ====
 
59
 
 
60
--echo [on master]
 
61
connection master;
 
62
CREATE TABLE t1(a INT PRIMARY KEY);
 
63
--echo [on slave]
 
64
sync_slave_with_master;
 
65
 
 
66
 
 
67
--echo ==== Test: SQL thread sees 'INSERT' of existing key ====
 
68
 
 
69
--echo ---- Prepare slave so that it will get duplicate key error ----
 
70
# This row will be in the way of the row inserted by master.
 
71
INSERT INTO t1 VALUES (1);
 
72
 
 
73
--echo ---- Insert rows on master ----
 
74
--echo [on master]
 
75
connection master;
 
76
# Insert the same row on master
 
77
INSERT INTO t1 VALUES (1);
 
78
save_master_pos;
 
79
SELECT * FROM t1;
 
80
 
 
81
--echo [on slave]
 
82
connection slave;
 
83
 
 
84
# If we are statement-logging or if slave_exec_mode=STRICT, we now
 
85
# expect to see an error on the slave.  Otherwise (i.e., we are
 
86
# row-logging and slave_exec_mode=IDEMPOTENT), we expect that the
 
87
# duplicate row is ignored by the slave and replication continues.
 
88
if (`SELECT @@global.binlog_format != 'ROW' OR @@global.slave_exec_mode = 'STRICT'`) {
 
89
  --echo ---- Wait until slave stops with an error ----
 
90
  # Wait until the slave tries to run the query, fails with duplicate
 
91
  # key error, and stops the SQL thread.
 
92
  let $slave_sql_errno= 1062; # ER_DUP_ENTRY
 
93
  source include/wait_for_slave_sql_error.inc;
 
94
  let $err= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
 
95
  --echo Last_SQL_Error = $err (expected "duplicate key" error)
 
96
  SELECT * FROM t1;
 
97
 
 
98
  --echo ---- Resolve the conflict on the slave and restart SQL thread ----
 
99
  DELETE FROM t1 WHERE a = 1;
 
100
  START SLAVE SQL_THREAD;
 
101
  source include/wait_for_slave_sql_to_start.inc;
 
102
}
 
103
 
 
104
--echo ---- Sync slave and verify that there is no error ----
 
105
sync_with_master;
 
106
let $err= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
 
107
--echo Last_SQL_Error = '$err' (expected no error)
 
108
SELECT * FROM t1;
 
109
 
 
110
 
 
111
--echo ==== Test: SQL thread sees 'DELETE' of non-existing row ====
 
112
 
 
113
--echo ---- On master, insert two rows, the second with binlogging off ----
 
114
--echo [on master]
 
115
connection master;
 
116
DELETE FROM t1;
 
117
INSERT INTO t1 VALUES (1);
 
118
 
 
119
--echo [on slave]
 
120
sync_slave_with_master;
 
121
DELETE FROM t1 WHERE a = 1;
 
122
 
 
123
--echo ---- On master, remove the row that does not exist on slave ----
 
124
--echo [on master]
 
125
connection master;
 
126
DELETE FROM t1 WHERE a = 1;
 
127
SELECT * FROM t1;
 
128
save_master_pos;
 
129
 
 
130
--echo [on slave]
 
131
connection slave;
 
132
 
 
133
# If we are row-logging and slave_exec_mode is STRICT, we now expect
 
134
# an error since the row to delete does not exist on slave.  Otherwise
 
135
# (i.e., either we are statement-logging or slave_exec_mode is
 
136
# IDEMPOTENT), the absence of the row to delete is ignored and
 
137
# replication continues.
 
138
if (`SELECT @@global.binlog_format = 'ROW' AND @@global.slave_exec_mode = 'STRICT'`) {
 
139
  --echo ---- Wait until slave stops with an error ----
 
140
  let $slave_sql_errno= 1032; # ER_KEY_NOT_FOUND
 
141
  source include/wait_for_slave_sql_error.inc;
 
142
  let $err= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
 
143
  --echo Last_SQL_Error = $err (expected "can't find record" error)
 
144
  SELECT * FROM t1;
 
145
 
 
146
  --echo ---- Resolve the conflict on the slave and restart SQL thread ----
 
147
  INSERT INTO t1 VALUES (1);
 
148
  START SLAVE SQL_THREAD;
 
149
  source include/wait_for_slave_sql_to_start.inc;
 
150
}
 
151
 
 
152
--echo ---- Sync slave and verify that there is no error ----
 
153
# The slave should sync ok, and SHOW SLAVE STATUS should give no
 
154
# error.
 
155
sync_with_master;
 
156
let $err= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
 
157
--echo Last_SQL_Error = $err (expected no error)
 
158
SELECT * FROM t1;
 
159
 
 
160
 
 
161
--echo ==== Clean up ====
 
162
 
 
163
--echo [on master]
 
164
connection master;
 
165
DROP TABLE t1;
 
166
 
 
167
--echo [on slave]
 
168
sync_slave_with_master;