...
1runOn:
2 - minServerVersion: "4.3.1"
3 topology: ["replicaset", "sharded", "load-balanced"]
4
5data:
6 - { _id: 1, x: 11 }
7 - { _id: 2, x: 22 }
8
9tests:
10 - description: "FindOneAndUpdate succeeds with RetryableWriteError from server"
11 failPoint:
12 configureFailPoint: failCommand
13 mode: { times: 1 }
14 data:
15 failCommands: ["findAndModify"]
16 errorCode: 112 # WriteConflict, not a retryable error code
17 errorLabels: ["RetryableWriteError"] # Override server behavior: send RetryableWriteError label with non-retryable error code
18 operation:
19 name: "findOneAndUpdate"
20 arguments:
21 filter: { _id: 1 }
22 update: { $inc: { x: 1 } }
23 returnDocument: "Before"
24 outcome: # Driver retries operation and it succeeds
25 result: { _id: 1, x: 11 }
26 collection:
27 data:
28 - { _id: 1, x: 12 }
29 - { _id: 2, x: 22 }
30
31 - description: "FindOneAndUpdate fails if server does not return RetryableWriteError"
32 failPoint:
33 configureFailPoint: failCommand
34 mode: { times: 1 }
35 data:
36 failCommands: ["findAndModify"]
37 errorCode: 11600 # InterruptedAtShutdown, normally a retryable error code
38 errorLabels: [] # Override server behavior: do not send RetryableWriteError label with retryable code
39 operation:
40 name: "findOneAndUpdate"
41 arguments:
42 filter: { _id: 1 }
43 update: { $inc: { x: 1 } }
44 returnDocument: "Before"
45 outcome:
46 error: true # Driver does not retry operation because there was no RetryableWriteError label on response
47 result:
48 errorLabelsOmit: ["RetryableWriteError"]
49 collection:
50 data:
51 - { _id: 1, x: 11 }
52 - { _id: 2, x: 22 }
View as plain text