Debian Codegraph @

mysql-test/suite/rpl/t/rpl_view_multi.test

raw
1 #
2 # This file contains test cases for bugs which involve views, several
3 # concurren connections and manifest themselves as wrong binary log
4 # sequence which results in broken replication. In principle we are
5 # mostly interested in SBR here but this test will also work with RBR.
6 #
7 --source include/master-slave.inc
8
9 --echo #
10 --echo # Bug #25144 "replication / binlog with view breaks".
11 --echo # Statements that used views didn't ensure that view were not modified
12 --echo # during their execution. Indeed this led to incorrect binary log with
13 --echo # statement based logging and as result to broken replication.
14 --echo #
15 #
16 # Suppress "unsafe" warnings.
17 #
18 disable_query_log;
19 call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
20 enable_query_log;
21
22
23 --disable_warnings
24 drop tables if exists t1, t2;
25 drop view if exists v1;
26 --enable_warnings
27 --echo # Syncing slave with master
28 --sync_slave_with_master
29
30 --disable_ps2_protocol
31 connect (master2,127.0.0.1,root,,test,$MASTER_MYPORT,);
32
33 connection master;
34 create table t1 (i int);
35 create table t2 (i int);
36 create view v1 as select * from t1;
37
38 --echo # First we try to concurrently execute statement that uses view
39 --echo # and statement that drops it. We use "user" locks as means to
40 --echo # suspend execution of first statement once it opens our view.
41 select get_lock("lock_bg25144", 1);
42
43 connection master1;
44 --send insert into v1 values (get_lock("lock_bg25144", 100))
45
46 connection master2;
47 let $wait_condition=
48 select count(*) = 1 from information_schema.processlist
49 where state = "User lock" and info like "insert into v1 %lock_bg25144%";
50 --source include/wait_condition.inc
51 --send drop view v1
52
53 connection master;
54 let $wait_condition=
55 select count(*) = 1 from information_schema.processlist
56 where state = "Waiting for table metadata lock" and info = "drop view v1";
57 --source include/wait_condition.inc
58
59 select release_lock("lock_bg25144");
60
61 connection master1;
62 --disable_warnings
63 --reap
64 --enable_warnings
65 select release_lock("lock_bg25144");
66
67 connection master2;
68 --reap
69
70 connection master;
71 --echo # Check that insertion through view did happen.
72 select * from t1;
73 --echo # Syncing slave with master
74 --sync_slave_with_master
75 --echo # Check that slave was able to replicate this sequence
76 --echo # which means that we got correct binlog order.
77 select * from t1;
78
79 connection master;
80 --echo # Now we will repeat the test by trying concurrently execute
81 --echo # statement that uses a view and statement that alters it.
82 create view v1 as select * from t1;
83
84 select get_lock("lock_bg25144", 1);
85
86 connection master1;
87 --send insert into v1 values (get_lock("lock_bg25144", 100))
88
89 connection master2;
90 let $wait_condition=
91 select count(*) = 1 from information_schema.processlist
92 where state = "User lock" and info like "insert into v1 %lock_bg25144%";
93 --source include/wait_condition.inc
94 --send alter view v1 as select * from t2
95
96 connection master;
97 let $wait_condition=
98 select count(*) = 1 from information_schema.processlist
99 where state = "Waiting for table metadata lock" and
100 info = "alter view v1 as select * from t2";
101 --source include/wait_condition.inc
102
103 select release_lock("lock_bg25144");
104
105 connection master1;
106 --disable_warnings
107 --reap
108 --enable_warnings
109 select release_lock("lock_bg25144");
110
111 connection master2;
112 --reap
113
114 connection master;
115
116 --echo # Second insertion should go to t1 as well.
117 select * from t1;
118 select * from t2;
119
120 --echo # Syncing slave with master
121 --sync_slave_with_master
122 --echo # Now let us check that statements were logged in proper order
123 --echo # So we have same result on slave.
124 select * from t1;
125 select * from t2;
126 --enable_ps2_protocol
127
128 connection master;
129 drop table t1, t2;
130 drop view v1;
131 --echo # Syncing slave with master
132 --sync_slave_with_master
133 --source include/rpl_end.inc