Debian Codegraph @

mysql-test/suite/ndb_rpl/t/ndb_rpl_skip.test

raw
1 --source include/have_ndb.inc
2 --source include/have_binlog_format_mixed_or_row.inc
3 --source suite/ndb_rpl/ndb_master-slave.inc
4
5 #
6 # ndb_rpl_skip.test
7 #
8 # Show behaviour of replica applier --slave-skip-errors option with Ndb
9 #
10 # Behaviours shown
11 # 1. Using slave-skip-errors to skip an epoch transaction
12 # results in a subsequent replication failure as Ndb
13 # detects that the epoch was started but not committed.
14 #
15 # 2. Using slave-skip-errors and ndb_applier_allow_skip_epoch=1
16 # avoids replication failure
17 #
18 # 3. When skipping an error in applying an epoch transaction,
19 # the whole epoch transaction is skipped.
20 #
21 # The ndb_rpl_skip-slave.opt file sets --slave-skip-errors=1022 so that
22 # uniqueness violations are skipped in replication
23 #
24 --connection master
25 create table t1 (a int not null, b int, c int, unique(c)) engine=ndb;
26
27 --echo Insert some records
28 #####
29
30 let $1=1000;
31 disable_query_log;
32 while ($1)
33 {
34 eval insert into t1 values($1, $1, $1);
35 dec $1;
36 }
37 enable_query_log;
38
39 --sync_slave_with_master
40 --echo Connect to replica and ensure data is there.
41 #####
42 --connection slave
43 select count(*) from t1;
44
45 # Errors from epoch sequence checking :
46 --disable_query_log
47 call mtr.add_suppression("Replica: SQL thread stopped as attempting to apply new epoch.*while lower received epoch.*has not been committed.*");
48 call mtr.add_suppression(".*Could not execute Write_rows event on table.*");
49 call mtr.add_suppression(".*Replica: Got error 173 'Unknown error code' from NDBCLUSTER.*");
50 call mtr.add_suppression(".*coordinator and worker threads are stopped.*");
51 --enable_query_log
52
53 --echo Make a replica side change
54 --echo This can cause uniqueness violations when we replicate data
55 ####
56 insert into t1 values (2001,2001,1001);
57 insert into t1 values (2002,2002,1002);
58 insert into t1 values (2003,2003,1003);
59
60 --echo Scenario 1 : skipping causes problem with epoch sequence check
61 --echo --------------------------------------------------------------
62
63 --connection master
64 --echo Cause a conflict
65 ###
66 insert into t1 values (1001,1001,1001); # Will conflict on c=1001
67
68 --echo Sync with master, will succeed
69 --sync_slave_with_master
70
71 --echo Show that row was not replicated to slave
72 --connection slave
73 select * from t1 where a=1001;
74
75 --echo Show that subsequent changes cause an error
76 --connection master
77 insert into t1 values (3000,3000,3000);
78
79 --echo Expect replication to stop with an error
80 --connection slave
81 --let $slave_sql_errno=1296
82 --source include/wait_for_slave_sql_error.inc
83
84 --echo Data not replicated
85 select * from t1 where a=3000;
86
87 --echo Simply starting the slave again should be enough
88 --echo to move on
89
90 start replica;
91 --connection master
92 --sync_slave_with_master
93
94 --connection slave
95 --echo Data now replicated
96 select * from t1 where a=3000;
97
98 --echo Scenario 2 : ndb_applier_allow_skip_epoch avoids slave stop
99 --echo -----------------------------------------------------------
100
101 --connection slave
102 show variables like 'ndb_applier_allow_skip_epoch';
103 set global ndb_applier_allow_skip_epoch = 1;
104 show variables like 'ndb_applier_allow_skip_epoch';
105
106 # Warning from epoch sequence checking when --ndb-applier-allow-skip-epoch is set
107 --disable_query_log
108 call mtr.add_suppression("Replica: SQL thread attempting to apply new epoch.*while lower received epoch.*has not been committed.*");
109 call mtr.add_suppression(".*coordinator and worker threads are stopped.*");
110 --enable_query_log
111
112 --connection master
113 --echo Cause a conflict
114 ###
115 insert into t1 values (1002,1002,1002); # Will conflict on c=1002
116
117 --echo Sync with master, will succeed
118 --sync_slave_with_master
119
120 --echo Show that row was not replicated to slave
121 --connection slave
122 select * from t1 where a=1001;
123
124 --echo Show that subsequent changes have no problem
125 --connection master
126 insert into t1 values (3001,3001,3001);
127
128 --sync_slave_with_master
129 --connection slave
130
131 --echo Data replicated
132 select * from t1 where a=3001;
133
134 --echo Show that whole epoch is skipped
135 --echo --------------------------------
136
137 --connection slave
138 --let $epoch1 = query_get_value('select epoch from mysql.ndb_apply_status;', epoch, 1)
139
140 --connection master
141 --echo Single transaction shown here
142
143 begin;
144 # ~500 rows of change - ok
145 update t1 set b=1234 where a < 500;
146 # 1 row in conflict
147 update t1 set b=1234, c=1003 where a = 500;
148 # ~500 rows of change - ok
149 update t1 set b=1234 where a > 500 and a <= 1000;
150 commit;
151
152 select count(1) from t1 where b=1234;
153
154 --sync_slave_with_master
155
156 --connection slave
157
158 --echo Replica has none of the changes
159
160 select count(1) from t1 where b=1234;
161 select * from t1 where a=500;
162
163 --echo Show epoch unchanged (diff is zero)
164 --disable_query_log
165 eval select epoch - $epoch1 as epoch_diff from mysql.ndb_apply_status;
166 --enable_query_log
167
168 set global ndb_applier_allow_skip_epoch=0;
169
170 --connection master
171 drop table t1;
172
173 # Cleanup Replication
174 --source include/rpl_end.inc