Debian Codegraph @

mysql-test/suite/rpl/r/rpl_read_only.result

raw
1 include/master-slave.inc
2 [connection master]
3 call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
4 connection master;
5 create user test;
6 grant all on test.* to test;
7 connection slave;
8 connect master2,127.0.0.1,test,,test,$MASTER_MYPORT,;
9 connect slave2,127.0.0.1,test,,test,$SLAVE_MYPORT,;
10 connection master1;
11 create table t1(a int) engine=InnoDB;
12 create table t2(a int) engine=MyISAM;
13 insert into t1 values(1001);
14 insert into t2 values(2001);
15 connection master;
16 set global read_only=1;
17 connection master1;
18 select @@read_only;
19 @@read_only
20 1
21 select * from t1;
22 a
23 1001
24 select * from t2;
25 a
26 2001
27 connection slave;
28 select @@read_only;
29 @@read_only
30 0
31 select * from t1;
32 a
33 1001
34 select * from t2;
35 a
36 2001
37 connection master;
38 set global read_only=0;
39 connection master1;
40 BEGIN;
41 connection master2;
42 BEGIN;
43 connection master;
44 select @@read_only;
45 @@read_only
46 0
47 set global read_only=1;
48 connection master1;
49 *** On SUPER USER connection ***
50 insert into t1 values(1002);
51 insert into t2 values(2002);
52 connection master2;
53 *** On regular USER connection ***
54 insert into t1 values(1003);
55 ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
56 insert into t2 values(2003);
57 ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
58 connection master1;
59 *** SUPER USER COMMIT (must succeed) ***
60 COMMIT;
61 connection master2;
62 *** regular USER COMMIT (must succeed - nothing to commit) ***
63 COMMIT;
64 connection master;
65 select @@read_only;
66 @@read_only
67 1
68 set global read_only=0;
69 connection master1;
70 insert into t1 values(1004);
71 insert into t2 values(2004);
72 select * from t1;
73 a
74 1001
75 1002
76 1004
77 select * from t2;
78 a
79 2001
80 2002
81 2004
82 connection slave;
83 select * from t1;
84 a
85 1001
86 1002
87 1004
88 select * from t2;
89 a
90 2001
91 2002
92 2004
93 connection slave1;
94 set global read_only=1;
95 connection slave;
96 select @@read_only;
97 @@read_only
98 1
99 show create table t1;
100 Table Create Table
101 t1 CREATE TABLE `t1` (
102 `a` int(11) DEFAULT NULL
103 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
104 show create table t2;
105 Table Create Table
106 t2 CREATE TABLE `t2` (
107 `a` int(11) DEFAULT NULL
108 ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
109 connection master;
110 insert into t1 values(1005);
111 insert into t2 values(2005);
112 select * from t1;
113 a
114 1001
115 1002
116 1004
117 1005
118 select * from t2;
119 a
120 2001
121 2002
122 2004
123 2005
124 connection slave;
125 connection slave;
126 select * from t1;
127 a
128 1001
129 1002
130 1004
131 1005
132 select * from t2;
133 a
134 2001
135 2002
136 2004
137 2005
138 connection slave2;
139 insert into t1 values(1006);
140 ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
141 insert into t2 values(2006);
142 ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
143 #
144 # MDEV-30978: On slave XA COMMIT/XA ROLLBACK fail to return an error in read-only mode
145 #
146 # Where a read-only server permits writes through replication, it
147 # should not permit user connections to commit/rollback XA transactions
148 # prepared via replication. This test ensure this behavior is prohibited
149 #
150 connection master;
151 xa start '1';
152 insert into t1 values (1007);
153 xa end '1';
154 xa prepare '1';
155 connection slave;
156 connection slave2;
157 xa commit '1';
158 ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
159 xa rollback '1';
160 ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
161 connection master;
162 xa rollback '1';
163 connection master;
164 drop user test;
165 drop table t1;
166 drop table t2;
167 connection slave;
168 set global read_only=0;
169 include/rpl_end.inc