1{
2  "runOn": [
3    {
4      "minServerVersion": "4.1.8",
5      "topology": [
6        "sharded"
7      ]
8    }
9  ],
10  "database_name": "transaction-tests",
11  "collection_name": "test",
12  "data": [],
13  "tests": [
14    {
15      "description": "commitTransaction explicit retries include recoveryToken",
16      "useMultipleMongoses": true,
17      "operations": [
18        {
19          "name": "startTransaction",
20          "object": "session0"
21        },
22        {
23          "name": "insertOne",
24          "object": "collection",
25          "arguments": {
26            "session": "session0",
27            "document": {
28              "_id": 1
29            }
30          },
31          "result": {
32            "insertedId": 1
33          }
34        },
35        {
36          "name": "commitTransaction",
37          "object": "session0"
38        },
39        {
40          "name": "commitTransaction",
41          "object": "session0"
42        },
43        {
44          "name": "commitTransaction",
45          "object": "session0"
46        }
47      ],
48      "expectations": [
49        {
50          "command_started_event": {
51            "command": {
52              "insert": "test",
53              "documents": [
54                {
55                  "_id": 1
56                }
57              ],
58              "ordered": true,
59              "readConcern": null,
60              "lsid": "session0",
61              "txnNumber": {
62                "$numberLong": "1"
63              },
64              "startTransaction": true,
65              "autocommit": false,
66              "writeConcern": null
67            },
68            "command_name": "insert",
69            "database_name": "transaction-tests"
70          }
71        },
72        {
73          "command_started_event": {
74            "command": {
75              "commitTransaction": 1,
76              "lsid": "session0",
77              "txnNumber": {
78                "$numberLong": "1"
79              },
80              "startTransaction": null,
81              "autocommit": false,
82              "writeConcern": null,
83              "recoveryToken": 42
84            },
85            "command_name": "commitTransaction",
86            "database_name": "admin"
87          }
88        },
89        {
90          "command_started_event": {
91            "command": {
92              "commitTransaction": 1,
93              "lsid": "session0",
94              "txnNumber": {
95                "$numberLong": "1"
96              },
97              "startTransaction": null,
98              "autocommit": false,
99              "writeConcern": {
100                "w": "majority",
101                "wtimeout": 10000
102              },
103              "recoveryToken": 42
104            },
105            "command_name": "commitTransaction",
106            "database_name": "admin"
107          }
108        },
109        {
110          "command_started_event": {
111            "command": {
112              "commitTransaction": 1,
113              "lsid": "session0",
114              "txnNumber": {
115                "$numberLong": "1"
116              },
117              "startTransaction": null,
118              "autocommit": false,
119              "writeConcern": {
120                "w": "majority",
121                "wtimeout": 10000
122              },
123              "recoveryToken": 42
124            },
125            "command_name": "commitTransaction",
126            "database_name": "admin"
127          }
128        }
129      ],
130      "outcome": {
131        "collection": {
132          "data": [
133            {
134              "_id": 1
135            }
136          ]
137        }
138      }
139    },
140    {
141      "description": "commitTransaction retry succeeds on new mongos",
142      "useMultipleMongoses": true,
143      "operations": [
144        {
145          "name": "startTransaction",
146          "object": "session0",
147          "arguments": {
148            "options": {
149              "writeConcern": {
150                "w": "majority"
151              }
152            }
153          }
154        },
155        {
156          "name": "insertOne",
157          "object": "collection",
158          "arguments": {
159            "session": "session0",
160            "document": {
161              "_id": 1
162            }
163          },
164          "result": {
165            "insertedId": 1
166          }
167        },
168        {
169          "name": "targetedFailPoint",
170          "object": "testRunner",
171          "arguments": {
172            "session": "session0",
173            "failPoint": {
174              "configureFailPoint": "failCommand",
175              "mode": {
176                "times": 1
177              },
178              "data": {
179                "failCommands": [
180                  "commitTransaction"
181                ],
182                "writeConcernError": {
183                  "code": 91,
184                  "errmsg": "Replication is being shut down",
185                  "errorLabels": [
186                    "RetryableWriteError"
187                  ]
188                }
189              }
190            }
191          }
192        },
193        {
194          "name": "commitTransaction",
195          "object": "session0"
196        }
197      ],
198      "expectations": [
199        {
200          "command_started_event": {
201            "command": {
202              "insert": "test",
203              "documents": [
204                {
205                  "_id": 1
206                }
207              ],
208              "ordered": true,
209              "readConcern": null,
210              "lsid": "session0",
211              "txnNumber": {
212                "$numberLong": "1"
213              },
214              "startTransaction": true,
215              "autocommit": false,
216              "writeConcern": null
217            },
218            "command_name": "insert",
219            "database_name": "transaction-tests"
220          }
221        },
222        {
223          "command_started_event": {
224            "command": {
225              "commitTransaction": 1,
226              "lsid": "session0",
227              "txnNumber": {
228                "$numberLong": "1"
229              },
230              "startTransaction": null,
231              "autocommit": false,
232              "writeConcern": {
233                "w": "majority"
234              },
235              "recoveryToken": 42
236            },
237            "command_name": "commitTransaction",
238            "database_name": "admin"
239          }
240        },
241        {
242          "command_started_event": {
243            "command": {
244              "commitTransaction": 1,
245              "lsid": "session0",
246              "txnNumber": {
247                "$numberLong": "1"
248              },
249              "startTransaction": null,
250              "autocommit": false,
251              "writeConcern": {
252                "w": "majority",
253                "wtimeout": 10000
254              },
255              "recoveryToken": 42
256            },
257            "command_name": "commitTransaction",
258            "database_name": "admin"
259          }
260        }
261      ],
262      "outcome": {
263        "collection": {
264          "data": [
265            {
266              "_id": 1
267            }
268          ]
269        }
270      }
271    },
272    {
273      "description": "commitTransaction retry fails on new mongos",
274      "useMultipleMongoses": true,
275      "clientOptions": {
276        "heartbeatFrequencyMS": 30000
277      },
278      "operations": [
279        {
280          "name": "startTransaction",
281          "object": "session0"
282        },
283        {
284          "name": "insertOne",
285          "object": "collection",
286          "arguments": {
287            "session": "session0",
288            "document": {
289              "_id": 1
290            }
291          },
292          "result": {
293            "insertedId": 1
294          }
295        },
296        {
297          "name": "targetedFailPoint",
298          "object": "testRunner",
299          "arguments": {
300            "session": "session0",
301            "failPoint": {
302              "configureFailPoint": "failCommand",
303              "mode": {
304                "times": 7
305              },
306              "data": {
307                "failCommands": [
308                  "commitTransaction",
309                  "isMaster"
310                ],
311                "closeConnection": true
312              }
313            }
314          }
315        },
316        {
317          "name": "commitTransaction",
318          "object": "session0",
319          "result": {
320            "errorLabelsContain": [
321              "TransientTransactionError"
322            ],
323            "errorLabelsOmit": [
324              "UnknownTransactionCommitResult"
325            ],
326            "errorCodeName": "NoSuchTransaction"
327          }
328        }
329      ],
330      "expectations": [
331        {
332          "command_started_event": {
333            "command": {
334              "insert": "test",
335              "documents": [
336                {
337                  "_id": 1
338                }
339              ],
340              "ordered": true,
341              "readConcern": null,
342              "lsid": "session0",
343              "txnNumber": {
344                "$numberLong": "1"
345              },
346              "startTransaction": true,
347              "autocommit": false,
348              "writeConcern": null
349            },
350            "command_name": "insert",
351            "database_name": "transaction-tests"
352          }
353        },
354        {
355          "command_started_event": {
356            "command": {
357              "commitTransaction": 1,
358              "lsid": "session0",
359              "txnNumber": {
360                "$numberLong": "1"
361              },
362              "startTransaction": null,
363              "autocommit": false,
364              "writeConcern": null,
365              "recoveryToken": 42
366            },
367            "command_name": "commitTransaction",
368            "database_name": "admin"
369          }
370        },
371        {
372          "command_started_event": {
373            "command": {
374              "commitTransaction": 1,
375              "lsid": "session0",
376              "txnNumber": {
377                "$numberLong": "1"
378              },
379              "startTransaction": null,
380              "autocommit": false,
381              "writeConcern": {
382                "w": "majority",
383                "wtimeout": 10000
384              },
385              "recoveryToken": 42
386            },
387            "command_name": "commitTransaction",
388            "database_name": "admin"
389          }
390        }
391      ],
392      "outcome": {
393        "collection": {
394          "data": []
395        }
396      }
397    },
398    {
399      "description": "abortTransaction sends recoveryToken",
400      "useMultipleMongoses": true,
401      "operations": [
402        {
403          "name": "startTransaction",
404          "object": "session0"
405        },
406        {
407          "name": "insertOne",
408          "object": "collection",
409          "arguments": {
410            "session": "session0",
411            "document": {
412              "_id": 1
413            }
414          },
415          "result": {
416            "insertedId": 1
417          }
418        },
419        {
420          "name": "targetedFailPoint",
421          "object": "testRunner",
422          "arguments": {
423            "session": "session0",
424            "failPoint": {
425              "configureFailPoint": "failCommand",
426              "mode": {
427                "times": 1
428              },
429              "data": {
430                "failCommands": [
431                  "abortTransaction"
432                ],
433                "closeConnection": true
434              }
435            }
436          }
437        },
438        {
439          "name": "abortTransaction",
440          "object": "session0"
441        }
442      ],
443      "expectations": [
444        {
445          "command_started_event": {
446            "command": {
447              "insert": "test",
448              "documents": [
449                {
450                  "_id": 1
451                }
452              ],
453              "ordered": true,
454              "readConcern": null,
455              "lsid": "session0",
456              "txnNumber": {
457                "$numberLong": "1"
458              },
459              "startTransaction": true,
460              "autocommit": false,
461              "writeConcern": null
462            },
463            "command_name": "insert",
464            "database_name": "transaction-tests"
465          }
466        },
467        {
468          "command_started_event": {
469            "command": {
470              "abortTransaction": 1,
471              "lsid": "session0",
472              "txnNumber": {
473                "$numberLong": "1"
474              },
475              "startTransaction": null,
476              "autocommit": false,
477              "writeConcern": null,
478              "recoveryToken": 42
479            },
480            "command_name": "abortTransaction",
481            "database_name": "admin"
482          }
483        },
484        {
485          "command_started_event": {
486            "command": {
487              "abortTransaction": 1,
488              "lsid": "session0",
489              "txnNumber": {
490                "$numberLong": "1"
491              },
492              "startTransaction": null,
493              "autocommit": false,
494              "writeConcern": null,
495              "recoveryToken": 42
496            },
497            "command_name": "abortTransaction",
498            "database_name": "admin"
499          }
500        }
501      ],
502      "outcome": {
503        "collection": {
504          "data": []
505        }
506      }
507    }
508  ]
509}
510