...
1runOn:
2 -
3 minServerVersion: "3.6"
4 topology: ["replicaset"]
5
6data:
7 - { _id: 1, x: 11 }
8
9tests:
10 -
11 description: "First command is retried"
12 failPoint:
13 configureFailPoint: onPrimaryTransactionalWrite
14 mode: { times: 1 }
15 operation:
16 name: "bulkWrite"
17 arguments:
18 requests:
19 -
20 name: "insertOne"
21 arguments:
22 document: { _id: 2, x: 22 }
23 -
24 name: "updateOne"
25 arguments:
26 filter: { _id: 2 }
27 update: { $inc: { x : 1 }}
28 -
29 name: "deleteOne"
30 arguments:
31 filter: { _id: 1 }
32 options: { ordered: true }
33 outcome:
34 result:
35 deletedCount: 1
36 insertedCount: 1
37 insertedIds: { 0: 2 }
38 matchedCount: 1
39 modifiedCount: 1
40 upsertedCount: 0
41 upsertedIds: { }
42 collection:
43 data:
44 - { _id: 2, x: 23 }
45 -
46 # Write operations in this ordered batch are intentionally sequenced so
47 # that each write command consists of a single statement, which will
48 # fail on the first attempt and succeed on the second, retry attempt.
49 description: "All commands are retried"
50 failPoint:
51 configureFailPoint: onPrimaryTransactionalWrite
52 mode: { times: 7 }
53 operation:
54 name: "bulkWrite"
55 arguments:
56 requests:
57 -
58 name: "insertOne"
59 arguments:
60 document: { _id: 2, x: 22 }
61 -
62 name: "updateOne"
63 arguments:
64 filter: { _id: 2 }
65 update: { $inc: { x : 1 }}
66 -
67 name: "insertOne"
68 arguments:
69 document: { _id: 3, x: 33 }
70 -
71 name: "updateOne"
72 arguments:
73 filter: { _id: 4, x: 44 }
74 update: { $inc: { x : 1 }}
75 upsert: true
76 -
77 name: "insertOne"
78 arguments:
79 document: { _id: 5, x: 55 }
80 -
81 name: "replaceOne"
82 arguments:
83 filter: { _id: 3 }
84 replacement: { _id: 3, x: 333 }
85 -
86 name: "deleteOne"
87 arguments:
88 filter: { _id: 1 }
89 options: { ordered: true }
90 outcome:
91 result:
92 deletedCount: 1
93 insertedCount: 3
94 insertedIds: { 0: 2, 2: 3, 4: 5 }
95 matchedCount: 2
96 modifiedCount: 2
97 upsertedCount: 1
98 upsertedIds: { 3: 4 }
99 collection:
100 data:
101 - { _id: 2, x: 23 }
102 - { _id: 3, x: 333 }
103 - { _id: 4, x: 45 }
104 - { _id: 5, x: 55 }
105 -
106 description: "Both commands are retried after their first statement fails"
107 failPoint:
108 configureFailPoint: onPrimaryTransactionalWrite
109 mode: { times: 2 }
110 operation:
111 name: "bulkWrite"
112 arguments:
113 requests:
114 -
115 name: "insertOne"
116 arguments:
117 document: { _id: 2, x: 22 }
118 -
119 name: "updateOne"
120 arguments:
121 filter: { _id: 1 }
122 update: { $inc: { x : 1 }}
123 -
124 name: "updateOne"
125 arguments:
126 filter: { _id: 2 }
127 update: { $inc: { x : 1 }}
128 options: { ordered: true }
129 outcome:
130 result:
131 deletedCount: 0
132 insertedCount: 1
133 insertedIds: { 0: 2 }
134 matchedCount: 2
135 modifiedCount: 2
136 upsertedCount: 0
137 upsertedIds: { }
138 collection:
139 data:
140 - { _id: 1, x: 12 }
141 - { _id: 2, x: 23 }
142 -
143 description: "Second command is retried after its second statement fails"
144 failPoint:
145 configureFailPoint: onPrimaryTransactionalWrite
146 mode: { skip: 2 }
147 operation:
148 name: "bulkWrite"
149 arguments:
150 requests:
151 -
152 name: "insertOne"
153 arguments:
154 document: { _id: 2, x: 22 }
155 -
156 name: "updateOne"
157 arguments:
158 filter: { _id: 1 }
159 update: { $inc: { x : 1 }}
160 -
161 name: "updateOne"
162 arguments:
163 filter: { _id: 2 }
164 update: { $inc: { x : 1 }}
165 options: { ordered: true }
166 outcome:
167 result:
168 deletedCount: 0
169 insertedCount: 1
170 insertedIds: { 0: 2 }
171 matchedCount: 2
172 modifiedCount: 2
173 upsertedCount: 0
174 upsertedIds: { }
175 collection:
176 data:
177 - { _id: 1, x: 12 }
178 - { _id: 2, x: 23 }
179 -
180 description: "BulkWrite with unordered execution"
181 failPoint:
182 configureFailPoint: onPrimaryTransactionalWrite
183 mode: { times: 1 }
184 operation:
185 name: "bulkWrite"
186 arguments:
187 requests:
188 -
189 name: "insertOne"
190 arguments:
191 document: { _id: 2, x: 22 }
192 -
193 name: "insertOne"
194 arguments:
195 document: { _id: 3, x: 33 }
196 options: { ordered: false }
197 outcome:
198 result:
199 deletedCount: 0
200 insertedCount: 2
201 insertedIds: { 0: 2, 1: 3 }
202 matchedCount: 0
203 modifiedCount: 0
204 upsertedCount: 0
205 upsertedIds: { }
206 collection:
207 data:
208 - { _id: 1, x: 11 }
209 - { _id: 2, x: 22 }
210 - { _id: 3, x: 33 }
211 -
212 description: "First insertOne is never committed"
213 failPoint:
214 configureFailPoint: onPrimaryTransactionalWrite
215 mode: { times: 2 }
216 data: { failBeforeCommitExceptionCode: 1 }
217 operation:
218 name: "bulkWrite"
219 arguments:
220 requests:
221 -
222 name: "insertOne"
223 arguments:
224 document: { _id: 2, x: 22 }
225 -
226 name: "updateOne"
227 arguments:
228 filter: { _id: 2 }
229 update: { $inc: { x : 1 }}
230 -
231 name: "deleteOne"
232 arguments:
233 filter: { _id: 1 }
234 options: { ordered: true }
235 outcome:
236 error: true
237 result:
238 deletedCount: 0
239 insertedCount: 0
240 insertedIds: { }
241 matchedCount: 0
242 modifiedCount: 0
243 upsertedCount: 0
244 upsertedIds: { }
245 collection:
246 data:
247 - { _id: 1, x: 11 }
248 -
249 description: "Second updateOne is never committed"
250 failPoint:
251 configureFailPoint: onPrimaryTransactionalWrite
252 mode: { skip: 1 }
253 data: { failBeforeCommitExceptionCode: 1 }
254 operation:
255 name: "bulkWrite"
256 arguments:
257 requests:
258 -
259 name: "insertOne"
260 arguments:
261 document: { _id: 2, x: 22 }
262 -
263 name: "updateOne"
264 arguments:
265 filter: { _id: 2 }
266 update: { $inc: { x : 1 }}
267 -
268 name: "deleteOne"
269 arguments:
270 filter: { _id: 1 }
271 options: { ordered: true }
272 outcome:
273 error: true
274 result:
275 deletedCount: 0
276 insertedCount: 1
277 insertedIds: { 0: 2 }
278 matchedCount: 0
279 modifiedCount: 0
280 upsertedCount: 0
281 upsertedIds: { }
282 collection:
283 data:
284 - { _id: 1, x: 11 }
285 - { _id: 2, x: 22 }
286 -
287 description: "Third updateOne is never committed"
288 failPoint:
289 configureFailPoint: onPrimaryTransactionalWrite
290 mode: { skip: 2 }
291 data: { failBeforeCommitExceptionCode: 1 }
292 operation:
293 name: "bulkWrite"
294 arguments:
295 requests:
296 -
297 name: "updateOne"
298 arguments:
299 filter: { _id: 1 }
300 update: { $inc: { x : 1 }}
301 -
302 name: "insertOne"
303 arguments:
304 document: { _id: 2, x: 22 }
305 -
306 name: "updateOne"
307 arguments:
308 filter: { _id: 2 }
309 update: { $inc: { x : 1 }}
310 options: { ordered: true }
311 outcome:
312 error: true
313 result:
314 deletedCount: 0
315 insertedCount: 1
316 insertedIds: { 1: 2 }
317 matchedCount: 1
318 modifiedCount: 1
319 upsertedCount: 0
320 upsertedIds: { }
321 collection:
322 data:
323 - { _id: 1, x: 12 }
324 - { _id: 2, x: 22 }
325 -
326 # The onPrimaryTransactionalWrite fail point only triggers for write
327 # operations that include a transaction ID. Therefore, it will not
328 # affect the initial deleteMany and will trigger once (and only once)
329 # for the first insertOne attempt.
330 description: "Single-document write following deleteMany is retried"
331 failPoint:
332 configureFailPoint: onPrimaryTransactionalWrite
333 mode: { times: 1 }
334 data: { failBeforeCommitExceptionCode: 1 }
335 operation:
336 name: "bulkWrite"
337 arguments:
338 requests:
339 -
340 name: "deleteMany"
341 arguments:
342 filter: { x: 11 }
343 -
344 name: "insertOne"
345 arguments:
346 document: { _id: 2, x: 22 }
347 options: { ordered: true }
348 outcome:
349 result:
350 deletedCount: 1
351 insertedCount: 1
352 insertedIds: { 1: 2 }
353 matchedCount: 0
354 modifiedCount: 0
355 upsertedCount: 0
356 upsertedIds: { }
357 collection:
358 data:
359 - { _id: 2, x: 22 }
360 -
361 # The onPrimaryTransactionalWrite fail point only triggers for write
362 # operations that include a transaction ID. Therefore, it will not
363 # affect the initial updateMany and will trigger once (and only once)
364 # for the first insertOne attempt.
365 description: "Single-document write following updateMany is retried"
366 failPoint:
367 configureFailPoint: onPrimaryTransactionalWrite
368 mode: { times: 1 }
369 data: { failBeforeCommitExceptionCode: 1 }
370 operation:
371 name: "bulkWrite"
372 arguments:
373 requests:
374 -
375 name: "updateMany"
376 arguments:
377 filter: { x: 11 }
378 update: { $inc: { x : 1 }}
379 -
380 name: "insertOne"
381 arguments:
382 document: { _id: 2, x: 22 }
383 options: { ordered: true }
384 outcome:
385 result:
386 deletedCount: 0
387 insertedCount: 1
388 insertedIds: { 1: 2 }
389 matchedCount: 1
390 modifiedCount: 1
391 upsertedCount: 0
392 upsertedIds: { }
393 collection:
394 data:
395 - { _id: 1, x: 12 }
396 - { _id: 2, x: 22 }
View as plain text