~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/suite/rpl/t/rpl_concurrency_error.test

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
###############################################################################
 
2
#BUG#44581 Slave stops when transaction with non-transactional table gets
 
3
#lock wait timeout
 
4
#
 
5
# In STMT and MIXED modes, a statement that changes both non-transactional and
 
6
# transactional tables must be written to the binary log whenever there are
 
7
# changes to non-transactional tables. This means that the statement gets into
 
8
# the # binary log even when the changes to the transactional tables fail. In
 
9
# particular, in the presence of a failure such statement is annotated with the
 
10
# error number and wrapped in a begin/rollback. On the slave, while applying
 
11
# the statement, it is expected the same failure and the rollback prevents the
 
12
# transactional changes to be persisted.
 
13
 
 
14
# This test aims to verify if a statement that updates both transactional and
 
15
# non-transacitonal tables and fails due to concurrency problems is correctly
 
16
# processed by the slave in the sense that the statements get into the binary
 
17
# log, the error is ignored and only the non-transactional tables are changed.
 
18
###############################################################################
 
19
 
 
20
--source include/master-slave.inc
 
21
--source include/have_innodb.inc
 
22
--source include/have_binlog_format_statement.inc
 
23
 
 
24
--echo ########################################################################
 
25
--echo #                             Environment
 
26
--echo ########################################################################
 
27
connection master;
 
28
 
 
29
CREATE TABLE t (i INT, PRIMARY KEY(i), f CHAR(8)) engine = Innodb;
 
30
CREATE TABLE n (d DATETIME, f CHAR(32)) engine = MyIsam;
 
31
 
 
32
DELIMITER |;
 
33
CREATE TRIGGER tr AFTER UPDATE ON t FOR EACH ROW 
 
34
BEGIN 
 
35
  INSERT INTO n VALUES ( now(), concat( 'updated t: ', old.f, ' -> ', new.f ) ); 
 
36
END |
 
37
DELIMITER ;|
 
38
 
 
39
INSERT INTO t VALUES (4,'black'), (2,'red'), (3,'yelow'), (1,'cyan');
 
40
 
 
41
connect (conn1, 127.0.0.1,root,,);
 
42
connect (conn2, 127.0.0.1,root,,);
 
43
 
 
44
--echo ########################################################################
 
45
--echo #                     Testing ER_LOCK_WAIT_TIMEOUT
 
46
--echo ########################################################################
 
47
 
 
48
let $type=2;
 
49
 
 
50
while ($type)
 
51
{
 
52
  let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
 
53
  connection conn1;
 
54
  if (`select $type = 2`)
 
55
  {
 
56
    SET AUTOCOMMIT = 1;
 
57
    BEGIN;
 
58
  }
 
59
  if (`select $type = 1`)
 
60
  {
 
61
    SET AUTOCOMMIT = 0;
 
62
  }
 
63
  eval UPDATE t SET f = 'yellow $type' WHERE i = 3;
 
64
  
 
65
  connection conn2;
 
66
  if (`select $type = 2`)
 
67
  {
 
68
    SET AUTOCOMMIT = 1;
 
69
    BEGIN;
 
70
  }
 
71
  if (`select $type = 1`)
 
72
  {
 
73
    SET AUTOCOMMIT = 0;
 
74
  }
 
75
  --error ER_LOCK_WAIT_TIMEOUT
 
76
  eval UPDATE t SET f = 'magenta $type' WHERE f = 'red';
 
77
  eval INSERT INTO t VALUES (5 + ($type * 10),"brown");
 
78
  INSERT INTO n VALUES (now(),"brown");
 
79
  
 
80
  connection conn1;
 
81
  COMMIT;
 
82
  
 
83
  connection conn2;
 
84
  ROLLBACK;
 
85
  --source include/show_binlog_events.inc
 
86
 
 
87
  let $binlog_start= query_get_value("SHOW MASTER STATUS", Position, 1);
 
88
  connection conn1;
 
89
  if (`select $type = 2`)
 
90
  {
 
91
    SET AUTOCOMMIT = 1;
 
92
    BEGIN;
 
93
  }
 
94
  if (`select $type = 1`)
 
95
  {
 
96
    SET AUTOCOMMIT = 0;
 
97
  }
 
98
  eval UPDATE t SET f = 'gray $type' WHERE i = 3;
 
99
  
 
100
  connection conn2;
 
101
  if (`select $type = 2`)
 
102
  {
 
103
    SET AUTOCOMMIT = 1;
 
104
    BEGIN;
 
105
  }
 
106
  if (`select $type = 1`)
 
107
  {
 
108
    SET AUTOCOMMIT = 0;
 
109
  }
 
110
  --error ER_LOCK_WAIT_TIMEOUT
 
111
  eval UPDATE t SET f = 'dark blue $type' WHERE f = 'red';
 
112
  eval INSERT INTO t VALUES (6 + ($type * 10),"brown");
 
113
  INSERT INTO n VALUES (now(),"brown");
 
114
  
 
115
  connection conn1;
 
116
  COMMIT;
 
117
  
 
118
  connection conn2;
 
119
  COMMIT;
 
120
  --source include/show_binlog_events.inc
 
121
  
 
122
  dec $type;
 
123
}
 
124
 
 
125
connection master;
 
126
sync_slave_with_master;
 
127
 
 
128
connection master;
 
129
let $diff_statement= SELECT * FROM t order by i;
 
130
source include/diff_master_slave.inc;
 
131
 
 
132
connection master;
 
133
let $diff_statement= SELECT * FROM n order by d, f;
 
134
source include/diff_master_slave.inc;
 
135
 
 
136
--echo ########################################################################
 
137
--echo #                                Cleanup
 
138
--echo ########################################################################
 
139
 
 
140
connection master;
 
141
DROP TRIGGER tr;
 
142
DROP TABLE t;
 
143
DROP TABLE n;
 
144
 
 
145
sync_slave_with_master;
 
146
 
 
147
connection master;
 
148
disconnect conn1;
 
149
disconnect conn2;