forked from mysql/mysql-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpl_crash_safe.test
230 lines (207 loc) · 7.61 KB
/
rpl_crash_safe.test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
###############################################################################
# This test case aims at checking if a slave does not go out of sync after
# injecting crashes at specific points. The following scenarios are analyzed:
#
# Following table represents the outcomes when Rli are on table.
# |------------+-----------------------+---------+---------+---------+---------|
# | SCENARIO # | SCENARIO | CRASH-1 | CRASH-2 | CRASH-3 | CRASH-4 |
# |------------+-----------------------+---------+---------+---------+---------|
# | 1 | T | O1 | O1 | O2 | O2 |
# | 2 | T-* | O1 | O1 | O2 | O2 |
# | 3 | B T T-* C | O1 | O1 | O2 | O2 |
# | 4 | B T-* T C | O1 | O1 | O2 | O2 |
# | 5 | N | O3 | O3 | O2 | O3 |
# | 6 | N-* | O3 | O3 | O2 | O3 |
# |------------+-----------------------+---------+---------+---------+---------|
#
# Legend:
#
# . T - Updates transactional table by calling insert/update/delete.
#
# . N - Updates non-transactional by calling insert/update/delete.
#
# . T-* - Updates transactional table through a trigger, procedure or function
# by calling insert/update/delete.
#
# . N-* - Updates non-transactional table through a trigger or function
# by calling insert/update/delete.
#
# . B - Begin.
#
# . C - Commit.
#
# . R - Rollback.
#
# For those transactions involving only transactional tables, faults are
# injected while committing a transaction at the following points:
#
# CRASH-1 - crash_before_update_pos - before updating the positions.
# CRASH-2 - crash_after_update_pos_before_apply - after updating the positions
# but before committing the transaction.
# CRASH-3 - crash_after_apply - after updating the position and committing the
# transaction.
#
# When a non-transactional table is updated, faults are injected at one point:
#
# CRASH-3 - crash_after_commit_and_update_pos - after committing and updating
# the positions.
#
# CRASH-4 - crash_after_commit_before_update_pos - after committing and
# updating positions in (FILE).
#
# After injecting the faults, we expect the following outcomes:
#
# O1. In this case, the slave shall correctly recover to "S" without going out
# of sync and process "tx".
#
# O2. In this case, the slave shall correctly recover to "S'" without going
# out of sync.
#
# O3. In this case, the slave shall recover to "S''" and re-execute "tx".
# In this case, the SQL Thread may fail due to duplicate keys, if any, and
# most likely the slave will become inconsistent. The user should manually
# check the slave and resolve the problems.
#
# where
#
# . S represents a database's state.
#
# . tx represents a transaction ended by either "C" or "R".
#
# . S' represents a database's state after processing "tx" and seen by
# concurrent transactions.
#
# . S'' represents a database's state after partially processing "tx"
# seen by concurrent transactions.
#
# Note however that we do not inject faults that generate "O3" as we are only
# interested in the cases that the slave can automatically recover.
# See WL#4801 for further details.
################################################################################
--echo ###################################################################################
--echo # PREPARE EXECUTION
--echo ###################################################################################
connection master;
--let $verbose= 1
--let $commands= configure
--source extra/rpl_tests/rpl_crash_safe.inc
--echo ###################################################################################
--echo # EXECUTE CASES CRASHING THE XID
--echo ###################################################################################
connection master;
--let $failures= d,crash_after_apply d,crash_before_update_pos d,crash_after_update_pos_before_apply d,crash_after_commit_before_update_pos
#
# Executes a set of tests while there are crash points in $failures.
#
while ($failures != '')
{
#
# Gets a crash point from the set of crash points in $failures and
# stores it into $failure.
#
--let $failure= `SELECT SUBSTRING_INDEX('$failures', ' ', 1)`
--echo
--echo
--echo
--let $commands= T
--source extra/rpl_tests/rpl_crash_safe.inc
--echo
--echo
--echo
--let $commands= T-trig
--source extra/rpl_tests/rpl_crash_safe.inc
--echo
--echo
--echo
--let $commands= T-func
--source extra/rpl_tests/rpl_crash_safe.inc
--echo
--echo
--echo
--let $commands= T-proc
--source extra/rpl_tests/rpl_crash_safe.inc
--echo
--echo
--echo
--let $commands= B T T-trig C
--source extra/rpl_tests/rpl_crash_safe.inc
--echo
--echo
--echo
--let $commands= B T T-func C
--source extra/rpl_tests/rpl_crash_safe.inc
--echo
--echo
--echo
--let $commands= B T T-proc C
--source extra/rpl_tests/rpl_crash_safe.inc
--echo
--echo
--echo
--let $commands= B T-trig T C
--source extra/rpl_tests/rpl_crash_safe.inc
--echo
--echo
--echo
--let $commands= B T-func T C
--source extra/rpl_tests/rpl_crash_safe.inc
--echo
--echo
--echo
--let $commands= B T-proc T C
--source extra/rpl_tests/rpl_crash_safe.inc
#
# Removes $failure from the set of crash points in $failures.
#
--let $failures= `SELECT LTRIM(SUBSTRING('$failures', LENGTH('$failure') + 1))`
}
--echo ###################################################################################
--echo # EXECUTE CASES CRASHING THE BEGIN/COMMIT
--echo ###################################################################################
--let $failures= d,crash_after_commit_and_update_pos
#
# Executes a set of tests while there are crash points in $failures.
#
while ($failures != '')
{
#
# Gets a crash point from the set of crash points in $failures and
# stores it into $failure.
#
--let $failure= `SELECT SUBSTRING_INDEX('$failures', ' ', 1)`
--echo
--echo
--echo
--let $commands= N
--source extra/rpl_tests/rpl_crash_safe.inc
--echo
--echo
--echo
--let $commands= N-trig
--source extra/rpl_tests/rpl_crash_safe.inc
--echo
--echo
--echo
--let $commands= N-func
--source extra/rpl_tests/rpl_crash_safe.inc
#
# Removes $failure from the set of crash points in $failures.
#
--let $failures= `SELECT LTRIM(SUBSTRING('$failures', LENGTH('$failure') + 1))`
}
--echo ###################################################################################
--echo # CHECK CONSISTENCY
--echo ###################################################################################
connection master;
--source include/sync_slave_sql_with_master.inc
connection master;
let $MYSQLD_DATADIR= `SELECT @@datadir`;
--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --set-gtid-purged=off --no-create-info test > $MYSQLD_DATADIR/test-crash-master.sql
--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --set-gtid-purged=off --no-create-info test > $MYSQLD_DATADIR/test-crash-slave.sql
--diff_files $MYSQLD_DATADIR/test-crash-master.sql $MYSQLD_DATADIR/test-crash-slave.sql
--echo ###################################################################################
--echo # CLEAN
--echo ###################################################################################
connection master;
--let $commands= clean
--source extra/rpl_tests/rpl_crash_safe.inc