1runOn:
2    -
3        minServerVersion: "4.0"
4        topology: ["replicaset"]
5    -
6        minServerVersion: "4.1.8"
7        topology: ["sharded"]
8
9database_name: &database_name "transaction-tests"
10collection_name: &collection_name "test"
11
12data: []
13
14tests:
15  - description: DuplicateKey errors do not contain transient label
16
17    operations:
18      - name: startTransaction
19        object: session0
20      - name: insertMany
21        object: collection
22        arguments:
23          session: session0
24          documents:
25            - _id: 1
26            - _id: 1
27        result:
28          errorLabelsOmit: ["TransientTransactionError", "UnknownTransactionCommitResult"]
29          # DuplicateKey error code included in the bulk write error message
30          # returned by the server
31          errorContains: E11000
32      - name: abortTransaction
33        object: session0
34
35    expectations:
36      - command_started_event:
37          command:
38            insert: *collection_name
39            documents:
40              - _id: 1
41              - _id: 1
42            ordered: true
43            readConcern:
44            lsid: session0
45            txnNumber:
46              $numberLong: "1"
47            startTransaction: true
48            autocommit: false
49            writeConcern:
50          command_name: insert
51          database_name: *database_name
52      - command_started_event:
53          command:
54            abortTransaction: 1
55            lsid: session0
56            txnNumber:
57              $numberLong: "1"
58            startTransaction:
59            autocommit: false
60            writeConcern:
61          command_name: abortTransaction
62          database_name: admin
63
64    outcome:
65      collection:
66        data: []
67
68  - description: NotMaster errors contain transient label
69
70    failPoint:
71      configureFailPoint: failCommand
72      mode: { times: 1 }
73      data:
74          failCommands: ["insert"]
75          errorCode: 10107  # NotMaster
76
77    operations:
78      - name: startTransaction
79        object: session0
80      - name: insertOne
81        object: collection
82        arguments:
83          session: session0
84          document:
85            _id: 1
86        result:
87          # Note, the server will return the errorLabel in this case.
88          errorLabelsContain: ["TransientTransactionError"]
89          errorLabelsOmit: ["RetryableWriteError", "UnknownTransactionCommitResult"]
90      - name: abortTransaction
91        object: session0
92
93    expectations:
94      - command_started_event:
95          command:
96            insert: *collection_name
97            documents:
98              - _id: 1
99            ordered: true
100            readConcern:
101            lsid: session0
102            txnNumber:
103              $numberLong: "1"
104            startTransaction: true
105            autocommit: false
106            writeConcern:
107          command_name: insert
108          database_name: *database_name
109      - command_started_event:
110          command:
111            abortTransaction: 1
112            lsid: session0
113            txnNumber:
114              $numberLong: "1"
115            startTransaction:
116            autocommit: false
117            writeConcern:
118          command_name: abortTransaction
119          database_name: admin
120
121    outcome:
122      collection:
123        data: []
124
125  - description: WriteConflict errors contain transient label
126
127    failPoint:
128      configureFailPoint: failCommand
129      mode: { times: 1 }
130      data:
131          failCommands: ["insert"]
132          errorCode: 112  # WriteConflict
133
134    operations:
135      - name: startTransaction
136        object: session0
137      - name: insertOne
138        object: collection
139        arguments:
140          session: session0
141          document:
142            _id: 1
143        result:
144          # Note, the server will return the errorLabel in this case.
145          errorLabelsContain: ["TransientTransactionError"]
146          errorLabelsOmit: ["RetryableWriteError", "UnknownTransactionCommitResult"]
147      - name: abortTransaction
148        object: session0
149
150    expectations:
151      - command_started_event:
152          command:
153            insert: *collection_name
154            documents:
155              - _id: 1
156            ordered: true
157            readConcern:
158            lsid: session0
159            txnNumber:
160              $numberLong: "1"
161            startTransaction: true
162            autocommit: false
163            writeConcern:
164          command_name: insert
165          database_name: *database_name
166      - command_started_event:
167          command:
168            abortTransaction: 1
169            lsid: session0
170            txnNumber:
171              $numberLong: "1"
172            startTransaction:
173            autocommit: false
174            writeConcern:
175          command_name: abortTransaction
176          database_name: admin
177
178    outcome:
179      collection:
180        data: []
181
182  - description: NoSuchTransaction errors contain transient label
183
184    failPoint:
185      configureFailPoint: failCommand
186      mode: { times: 1 }
187      data:
188          failCommands: ["insert"]
189          errorCode: 251  # NoSuchTransaction
190
191    operations:
192      - name: startTransaction
193        object: session0
194      - name: insertOne
195        object: collection
196        arguments:
197          session: session0
198          document:
199            _id: 1
200        result:
201          # Note, the server will return the errorLabel in this case.
202          errorLabelsContain: ["TransientTransactionError"]
203          errorLabelsOmit: ["RetryableWriteError", "UnknownTransactionCommitResult"]
204      - name: abortTransaction
205        object: session0
206
207    expectations:
208      - command_started_event:
209          command:
210            insert: *collection_name
211            documents:
212              - _id: 1
213            ordered: true
214            readConcern:
215            lsid: session0
216            txnNumber:
217              $numberLong: "1"
218            startTransaction: true
219            autocommit: false
220            writeConcern:
221          command_name: insert
222          database_name: *database_name
223      - command_started_event:
224          command:
225            abortTransaction: 1
226            lsid: session0
227            txnNumber:
228              $numberLong: "1"
229            startTransaction:
230            autocommit: false
231            writeConcern:
232          command_name: abortTransaction
233          database_name: admin
234
235    outcome:
236      collection:
237        data: []
238
239  - description: NoSuchTransaction errors on commit contain transient label
240
241    failPoint:
242      configureFailPoint: failCommand
243      mode: { times: 1 }
244      data:
245          failCommands: ["commitTransaction"]
246          errorCode: 251  # NoSuchTransaction
247
248    operations:
249      - name: startTransaction
250        object: session0
251      - name: insertOne
252        object: collection
253        arguments:
254          session: session0
255          document:
256            _id: 1
257        result:
258          insertedId: 1
259      - name: commitTransaction
260        object: session0
261        result:
262          # Note, the server will return the errorLabel in this case.
263          errorLabelsContain: ["TransientTransactionError"]
264          errorLabelsOmit: ["RetryableWriteError", "UnknownTransactionCommitResult"]
265
266    expectations:
267      - command_started_event:
268          command:
269            insert: *collection_name
270            documents:
271              - _id: 1
272            ordered: true
273            readConcern:
274            lsid: session0
275            txnNumber:
276              $numberLong: "1"
277            startTransaction: true
278            autocommit: false
279            writeConcern:
280          command_name: insert
281          database_name: *database_name
282      - command_started_event:
283          command:
284            commitTransaction: 1
285            lsid: session0
286            txnNumber:
287              $numberLong: "1"
288            startTransaction:
289            autocommit: false
290            writeConcern:
291          command_name: commitTransaction
292          database_name: admin
293
294    outcome:
295      collection:
296        data: []
297
298  - description: add TransientTransactionError label to connection errors, but do not add RetryableWriteError label
299
300    failPoint:
301      configureFailPoint: failCommand
302      mode: { times: 4 }
303      data:
304          failCommands: ["insert", "find", "aggregate", "distinct"]
305          closeConnection: true
306
307    operations:
308      - name: startTransaction
309        object: session0
310      - name: insertOne
311        object: collection
312        arguments:
313          session: session0
314          document:
315            _id: 1
316        result: &transient_label_only
317          errorLabelsContain: ["TransientTransactionError"]
318          # While a connection error would normally be retryable, these are not because
319          # they occur within a transaction; ensure the driver does not add the
320          # RetryableWriteError label to these errors.
321          errorLabelsOmit: ["RetryableWriteError", "UnknownTransactionCommitResult"]
322      - name: find
323        object: collection
324        arguments:
325          session: session0
326        result: *transient_label_only
327      - name: aggregate
328        object: collection
329        arguments:
330          pipeline:
331            - $project:
332                _id: 1
333          session: session0
334        result: *transient_label_only
335      - name: distinct
336        object: collection
337        arguments:
338          fieldName: _id
339          session: session0
340        result: *transient_label_only
341      - name: abortTransaction
342        object: session0
343
344    expectations:
345      - command_started_event:
346          command:
347            insert: *collection_name
348            documents:
349              - _id: 1
350            ordered: true
351            readConcern:
352            lsid: session0
353            txnNumber:
354              $numberLong: "1"
355            startTransaction: true
356            autocommit: false
357            writeConcern:
358          command_name: insert
359          database_name: *database_name
360      - command_started_event:
361          command:
362            find: *collection_name
363            readConcern:
364            lsid: session0
365            txnNumber:
366              $numberLong: "1"
367            startTransaction:
368            autocommit: false
369          command_name: find
370          database_name: *database_name
371      - command_started_event:
372          command:
373            aggregate: *collection_name
374            pipeline:
375              - $project:
376                  _id: 1
377            cursor: {}
378            readConcern:
379            lsid: session0
380            txnNumber:
381              $numberLong: "1"
382            startTransaction:
383            autocommit: false
384          command_name: aggregate
385          database_name: *database_name
386      - command_started_event:
387          command:
388            distinct: *collection_name
389            key: _id
390            lsid: session0
391            readConcern:
392            txnNumber:
393              $numberLong: "1"
394            startTransaction:
395            autocommit: false
396          command_name: distinct
397          database_name: *database_name
398      - command_started_event:
399          command:
400            abortTransaction: 1
401            lsid: session0
402            txnNumber:
403              $numberLong: "1"
404            startTransaction:
405            autocommit: false
406            writeConcern:
407          command_name: abortTransaction
408          database_name: admin
409
410    outcome:
411      collection:
412        data: []
413
414  - description: add RetryableWriteError and UnknownTransactionCommitResult labels to connection errors
415
416    failPoint:
417      configureFailPoint: failCommand
418      mode: { times: 2 }
419      data:
420          failCommands: ["commitTransaction"]
421          closeConnection: true
422
423    operations:
424      - name: startTransaction
425        object: session0
426      - name: insertOne
427        object: collection
428        arguments:
429          session: session0
430          document:
431            _id: 1
432        result:
433          insertedId: 1
434      - name: commitTransaction
435        object: session0
436        result:
437          errorLabelsContain: ["RetryableWriteError", "UnknownTransactionCommitResult"]
438          errorLabelsOmit: ["TransientTransactionError"]
439      - name: commitTransaction
440        object: session0
441
442    expectations:
443      - command_started_event:
444          command:
445            insert: *collection_name
446            documents:
447              - _id: 1
448            ordered: true
449            readConcern:
450            lsid: session0
451            txnNumber:
452              $numberLong: "1"
453            startTransaction: true
454            autocommit: false
455            writeConcern:
456          command_name: insert
457          database_name: *database_name
458      - command_started_event:
459          command:
460            commitTransaction: 1
461            lsid: session0
462            txnNumber:
463              $numberLong: "1"
464            startTransaction:
465            autocommit: false
466            writeConcern:
467          command_name: commitTransaction
468          database_name: admin
469      - command_started_event:
470          command:
471            commitTransaction: 1
472            lsid: session0
473            txnNumber:
474              $numberLong: "1"
475            startTransaction:
476            autocommit: false
477            # commitTransaction applies w:majority on retries
478            writeConcern: { w: majority, wtimeout: 10000 }
479          command_name: commitTransaction
480          database_name: admin
481      - command_started_event:
482          command:
483            commitTransaction: 1
484            lsid: session0
485            txnNumber:
486              $numberLong: "1"
487            startTransaction:
488            autocommit: false
489            writeConcern: { w: majority, wtimeout: 10000 }
490          command_name: commitTransaction
491          database_name: admin
492
493    outcome:
494      collection:
495        data:
496          - _id: 1
497
498  - description: add RetryableWriteError and UnknownTransactionCommitResult labels to retryable commit errors
499
500    failPoint:
501      configureFailPoint: failCommand
502      mode: { times: 2 }
503      data:
504          failCommands: ["commitTransaction"]
505          errorCode: 11602  # InterruptedDueToReplStateChange
506          errorLabels: ["RetryableWriteError"]
507
508    operations:
509      - name: startTransaction
510        object: session0
511      - name: insertOne
512        object: collection
513        arguments:
514          session: session0
515          document:
516            _id: 1
517        result:
518          insertedId: 1
519      - name: commitTransaction
520        object: session0
521        result:
522          errorLabelsContain: ["RetryableWriteError", "UnknownTransactionCommitResult"]
523          errorLabelsOmit: ["TransientTransactionError"]
524      - name: commitTransaction
525        object: session0
526
527    expectations:
528      - command_started_event:
529          command:
530            insert: *collection_name
531            documents:
532              - _id: 1
533            ordered: true
534            readConcern:
535            lsid: session0
536            txnNumber:
537              $numberLong: "1"
538            startTransaction: true
539            autocommit: false
540            writeConcern:
541          command_name: insert
542          database_name: *database_name
543      - command_started_event:
544          command:
545            commitTransaction: 1
546            lsid: session0
547            txnNumber:
548              $numberLong: "1"
549            startTransaction:
550            autocommit: false
551            writeConcern:
552          command_name: commitTransaction
553          database_name: admin
554      - command_started_event:
555          command:
556            commitTransaction: 1
557            lsid: session0
558            txnNumber:
559              $numberLong: "1"
560            startTransaction:
561            autocommit: false
562            # commitTransaction applies w:majority on retries
563            writeConcern: { w: majority, wtimeout: 10000 }
564          command_name: commitTransaction
565          database_name: admin
566      - command_started_event:
567          command:
568            commitTransaction: 1
569            lsid: session0
570            txnNumber:
571              $numberLong: "1"
572            startTransaction:
573            autocommit: false
574            writeConcern: { w: majority, wtimeout: 10000 }
575          command_name: commitTransaction
576          database_name: admin
577
578    outcome:
579      collection:
580        data:
581          - _id: 1
582
583  - description: add RetryableWriteError and UnknownTransactionCommitResult labels to writeConcernError ShutdownInProgress
584
585    failPoint:
586      configureFailPoint: failCommand
587      mode: { times: 2 }
588      data:
589          failCommands: ["commitTransaction"]
590          writeConcernError:
591            code: 91
592            errmsg: Replication is being shut down
593            errorLabels: ["RetryableWriteError"]
594
595    operations:
596      - name: startTransaction
597        object: session0
598        arguments:
599          options:
600            writeConcern:
601              w: majority
602      - name: insertOne
603        object: collection
604        arguments:
605          session: session0
606          document:
607            _id: 1
608        result:
609          insertedId: 1
610      - name: commitTransaction
611        object: session0
612        result:
613          errorLabelsContain: ["RetryableWriteError", "UnknownTransactionCommitResult"]
614          errorLabelsOmit: ["TransientTransactionError"]
615      - name: commitTransaction
616        object: session0
617
618    expectations:
619      - command_started_event:
620          command:
621            insert: *collection_name
622            documents:
623              - _id: 1
624            ordered: true
625            readConcern:
626            lsid: session0
627            txnNumber:
628              $numberLong: "1"
629            startTransaction: true
630            autocommit: false
631            writeConcern:
632          command_name: insert
633          database_name: *database_name
634      - command_started_event:
635          command:
636            commitTransaction: 1
637            lsid: session0
638            txnNumber:
639              $numberLong: "1"
640            startTransaction:
641            autocommit: false
642            writeConcern:
643              w: majority
644          command_name: commitTransaction
645          database_name: admin
646      - command_started_event:
647          command:
648            commitTransaction: 1
649            lsid: session0
650            txnNumber:
651              $numberLong: "1"
652            startTransaction:
653            autocommit: false
654            # commitTransaction applies w:majority on retries
655            writeConcern: { w: majority, wtimeout: 10000 }
656          command_name: commitTransaction
657          database_name: admin
658      - command_started_event:
659          command:
660            commitTransaction: 1
661            lsid: session0
662            txnNumber:
663              $numberLong: "1"
664            startTransaction:
665            autocommit: false
666            # commitTransaction applies w:majority on retries
667            writeConcern: { w: majority, wtimeout: 10000 }
668          command_name: commitTransaction
669          database_name: admin
670
671    outcome:
672      collection:
673        data:
674          - _id: 1
675
676  - description: do not add RetryableWriteError label to writeConcernError ShutdownInProgress that occurs within transaction
677
678    failPoint:
679      configureFailPoint: failCommand
680      mode: { times: 1 }
681      data:
682          failCommands: ["insert"]
683          writeConcernError:
684            code: 91
685            errmsg: Replication is being shut down
686
687    operations:
688      - name: startTransaction
689        object: session0
690        arguments:
691          options:
692            writeConcern:
693              w: majority
694      - name: insertOne
695        object: collection
696        arguments:
697          session: session0
698          document:
699            _id: 1
700        result:
701          errorLabelsContain: []
702          errorLabelsOmit: ["RetryableWriteError", "TransientTransactionError", "UnknownTransactionCommitResult"]
703      - name: abortTransaction
704        object: session0
705
706    expectations:
707      - command_started_event:
708          command:
709            insert: *collection_name
710            documents:
711              - _id: 1
712            ordered: true
713            readConcern:
714            lsid: session0
715            txnNumber:
716              $numberLong: "1"
717            startTransaction: true
718            autocommit: false
719          command_name: insert
720          database_name: *database_name
721      - command_started_event:
722          command:
723            abortTransaction: 1
724            lsid: session0
725            txnNumber:
726              $numberLong: "1"
727            startTransaction:
728            autocommit: false
729          command_name: abortTransaction
730          database_name: admin
731
732    outcome:
733      collection:
734        data: []
735
736  - description: add UnknownTransactionCommitResult label to writeConcernError WriteConcernFailed
737
738    failPoint:
739      configureFailPoint: failCommand
740      mode: { times: 1 }
741      data:
742          failCommands: ["commitTransaction"]
743          writeConcernError:
744            code: 64  # WriteConcernFailed without wtimeout
745            errmsg: multiple errors reported
746
747    operations:
748      - name: startTransaction
749        object: session0
750        arguments:
751          options:
752            writeConcern:
753              w: majority
754      - name: insertOne
755        object: collection
756        arguments:
757          session: session0
758          document:
759            _id: 1
760        result:
761          insertedId: 1
762      - name: commitTransaction
763        object: session0
764        result:
765          errorLabelsContain: ["UnknownTransactionCommitResult"]
766          errorLabelsOmit: ["RetryableWriteError", "TransientTransactionError"]
767      - name: commitTransaction
768        object: session0
769
770    expectations:
771      - command_started_event:
772          command:
773            insert: *collection_name
774            documents:
775              - _id: 1
776            ordered: true
777            readConcern:
778            lsid: session0
779            txnNumber:
780              $numberLong: "1"
781            startTransaction: true
782            autocommit: false
783            writeConcern:
784          command_name: insert
785          database_name: *database_name
786      - command_started_event:
787          command:
788            commitTransaction: 1
789            lsid: session0
790            txnNumber:
791              $numberLong: "1"
792            startTransaction:
793            autocommit: false
794            writeConcern:
795              w: majority
796          command_name: commitTransaction
797          database_name: admin
798      - command_started_event:
799          command:
800            commitTransaction: 1
801            lsid: session0
802            txnNumber:
803              $numberLong: "1"
804            startTransaction:
805            autocommit: false
806            # commitTransaction applies w:majority on retries
807            writeConcern: { w: majority, wtimeout: 10000 }
808          command_name: commitTransaction
809          database_name: admin
810
811    outcome:
812      collection:
813        data:
814          - _id: 1
815
816  - description: add UnknownTransactionCommitResult label to writeConcernError WriteConcernFailed with wtimeout
817
818    failPoint:
819      configureFailPoint: failCommand
820      mode: { times: 1 }
821      data:
822          failCommands: ["commitTransaction"]
823          writeConcernError:
824            code: 64
825            codeName: WriteConcernFailed
826            errmsg: waiting for replication timed out
827            errInfo: {wtimeout: True}
828
829    operations:
830      - name: startTransaction
831        object: session0
832        arguments:
833          options:
834            writeConcern:
835              w: majority
836      - name: insertOne
837        object: collection
838        arguments:
839          session: session0
840          document:
841            _id: 1
842        result:
843          insertedId: 1
844      - name: commitTransaction
845        object: session0
846        result:
847          errorLabelsContain: ["UnknownTransactionCommitResult"]
848          errorLabelsOmit: ["RetryableWriteError", "TransientTransactionError"]
849      - name: commitTransaction
850        object: session0
851
852    expectations:
853      - command_started_event:
854          command:
855            insert: *collection_name
856            documents:
857              - _id: 1
858            ordered: true
859            readConcern:
860            lsid: session0
861            txnNumber:
862              $numberLong: "1"
863            startTransaction: true
864            autocommit: false
865            writeConcern:
866          command_name: insert
867          database_name: *database_name
868      - command_started_event:
869          command:
870            commitTransaction: 1
871            lsid: session0
872            txnNumber:
873              $numberLong: "1"
874            startTransaction:
875            autocommit: false
876            writeConcern:
877              w: majority
878          command_name: commitTransaction
879          database_name: admin
880      - command_started_event:
881          command:
882            commitTransaction: 1
883            lsid: session0
884            txnNumber:
885              $numberLong: "1"
886            startTransaction:
887            autocommit: false
888            # commitTransaction applies w:majority on retries
889            writeConcern: { w: majority, wtimeout: 10000 }
890          command_name: commitTransaction
891          database_name: admin
892
893    outcome:
894      collection:
895        data:
896          - _id: 1
897
898  - description: omit UnknownTransactionCommitResult label from writeConcernError UnsatisfiableWriteConcern
899
900    failPoint:
901      configureFailPoint: failCommand
902      mode: { times: 1 }
903      data:
904          failCommands: ["commitTransaction"]
905          writeConcernError:
906            code: 100  # UnsatisfiableWriteConcern
907            errmsg: Not enough data-bearing nodes
908
909    operations:
910      - name: startTransaction
911        object: session0
912        arguments:
913          options:
914            writeConcern:
915              w: majority
916      - name: insertOne
917        object: collection
918        arguments:
919          session: session0
920          document:
921            _id: 1
922        result:
923          insertedId: 1
924      - name: commitTransaction
925        object: session0
926        result:
927          errorLabelsOmit: ["RetryableWriteError", "TransientTransactionError", "UnknownTransactionCommitResult"]
928
929    expectations:
930      - command_started_event:
931          command:
932            insert: *collection_name
933            documents:
934              - _id: 1
935            ordered: true
936            readConcern:
937            lsid: session0
938            txnNumber:
939              $numberLong: "1"
940            startTransaction: true
941            autocommit: false
942            writeConcern:
943          command_name: insert
944          database_name: *database_name
945      - command_started_event:
946          command:
947            commitTransaction: 1
948            lsid: session0
949            txnNumber:
950              $numberLong: "1"
951            startTransaction:
952            autocommit: false
953            writeConcern:
954              w: majority
955          command_name: commitTransaction
956          database_name: admin
957
958    outcome:
959      collection:
960        data:
961          - _id: 1
962
963  - description: omit UnknownTransactionCommitResult label from writeConcernError UnknownReplWriteConcern
964
965    failPoint:
966      configureFailPoint: failCommand
967      mode: { times: 1 }
968      data:
969          failCommands: ["commitTransaction"]
970          writeConcernError:
971            code: 79  # UnknownReplWriteConcern
972            errmsg: No write concern mode named 'blah' found in replica set configuration
973
974    operations:
975      - name: startTransaction
976        object: session0
977        arguments:
978          options:
979            writeConcern:
980              w: majority
981      - name: insertOne
982        object: collection
983        arguments:
984          session: session0
985          document:
986            _id: 1
987        result:
988          insertedId: 1
989      - name: commitTransaction
990        object: session0
991        result:
992          errorLabelsOmit: ["RetryableWriteConcern", "TransientTransactionError", "UnknownTransactionCommitResult"]
993
994    expectations:
995      - command_started_event:
996          command:
997            insert: *collection_name
998            documents:
999              - _id: 1
1000            ordered: true
1001            readConcern:
1002            lsid: session0
1003            txnNumber:
1004              $numberLong: "1"
1005            startTransaction: true
1006            autocommit: false
1007            writeConcern:
1008          command_name: insert
1009          database_name: *database_name
1010      - command_started_event:
1011          command:
1012            commitTransaction: 1
1013            lsid: session0
1014            txnNumber:
1015              $numberLong: "1"
1016            startTransaction:
1017            autocommit: false
1018            writeConcern:
1019              w: majority
1020          command_name: commitTransaction
1021          database_name: admin
1022
1023    outcome:
1024      collection:
1025        data:
1026          - _id: 1
1027
1028  - description: do not add UnknownTransactionCommitResult label to MaxTimeMSExpired inside transactions
1029
1030    failPoint:
1031      configureFailPoint: failCommand
1032      mode: { times: 1 }
1033      data:
1034        failCommands: ["aggregate"]
1035        errorCode: 50  # MaxTimeMSExpired
1036
1037    operations:
1038      - name: startTransaction
1039        object: session0
1040      - name: insertOne
1041        object: collection
1042        arguments:
1043          session: session0
1044          document:
1045            _id: 1
1046        result:
1047          insertedId: 1
1048      - name: aggregate
1049        object: collection
1050        arguments:
1051          pipeline:
1052            - $project:
1053                _id: 1
1054          maxTimeMS: 60000
1055          session: session0
1056        result:
1057          errorLabelsOmit: ["RetryableWriteError", "UnknownTransactionCommitResult", "TransientTransactionError"]
1058      - name: abortTransaction
1059        object: session0
1060
1061    expectations:
1062      - command_started_event:
1063          command:
1064            insert: *collection_name
1065            documents:
1066              - _id: 1
1067            ordered: true
1068            readConcern:
1069            lsid: session0
1070            txnNumber:
1071              $numberLong: "1"
1072            startTransaction: true
1073            autocommit: false
1074            writeConcern:
1075          command_name: insert
1076          database_name: *database_name
1077      - command_started_event:
1078          command:
1079            aggregate: *collection_name
1080            pipeline:
1081              - $project:
1082                  _id: 1
1083            cursor: {}
1084            readConcern:
1085            lsid: session0
1086            txnNumber:
1087              $numberLong: "1"
1088            autocommit: false
1089            maxTimeMS: 60000
1090          command_name: aggregate
1091          database_name: *database_name
1092      - command_started_event:
1093          command:
1094            abortTransaction: 1
1095            lsid: session0
1096            txnNumber:
1097              $numberLong: "1"
1098            startTransaction:
1099            autocommit: false
1100            writeConcern:
1101          command_name: abortTransaction
1102          database_name: admin
1103
1104    outcome:
1105      collection:
1106        data: []
1107
1108  - description: add UnknownTransactionCommitResult label to MaxTimeMSExpired
1109
1110    failPoint:
1111      configureFailPoint: failCommand
1112      mode: { times: 1 }
1113      data:
1114          failCommands: ["commitTransaction"]
1115          errorCode: 50  # MaxTimeMSExpired
1116
1117    operations:
1118      - name: startTransaction
1119        object: session0
1120        arguments:
1121          options:
1122            writeConcern:
1123              w: majority
1124            maxCommitTimeMS: 60000
1125      - name: insertOne
1126        object: collection
1127        arguments:
1128          session: session0
1129          document:
1130            _id: 1
1131        result:
1132          insertedId: 1
1133      - name: commitTransaction
1134        object: session0
1135        result:
1136          errorLabelsContain: ["UnknownTransactionCommitResult"]
1137          errorLabelsOmit: ["RetryableWriteError", "TransientTransactionError"]
1138      - name: commitTransaction
1139        object: session0
1140
1141    expectations:
1142      - command_started_event:
1143          command:
1144            insert: *collection_name
1145            documents:
1146              - _id: 1
1147            ordered: true
1148            readConcern:
1149            lsid: session0
1150            txnNumber:
1151              $numberLong: "1"
1152            startTransaction: true
1153            autocommit: false
1154            writeConcern:
1155          command_name: insert
1156          database_name: *database_name
1157      - command_started_event:
1158          command:
1159            commitTransaction: 1
1160            lsid: session0
1161            txnNumber:
1162              $numberLong: "1"
1163            startTransaction:
1164            autocommit: false
1165            writeConcern:
1166              w: majority
1167            maxTimeMS: 60000
1168          command_name: commitTransaction
1169          database_name: admin
1170      - command_started_event:
1171          command:
1172            commitTransaction: 1
1173            lsid: session0
1174            txnNumber:
1175              $numberLong: "1"
1176            startTransaction:
1177            autocommit: false
1178            # commitTransaction applies w:majority on retries
1179            writeConcern: { w: majority, wtimeout: 10000 }
1180            maxTimeMS: 60000
1181          command_name: commitTransaction
1182          database_name: admin
1183
1184    outcome:
1185      collection:
1186        data:
1187          - _id: 1
1188
1189  - description: add UnknownTransactionCommitResult label to writeConcernError MaxTimeMSExpired
1190
1191    failPoint:
1192      configureFailPoint: failCommand
1193      mode: { times: 1 }
1194      data:
1195          failCommands: ["commitTransaction"]
1196          writeConcernError:
1197            code: 50  # MaxTimeMSExpired
1198            errmsg: operation exceeded time limit
1199
1200    operations:
1201      - name: startTransaction
1202        object: session0
1203        arguments:
1204          options:
1205            writeConcern:
1206              w: majority
1207            maxCommitTimeMS: 60000
1208      - name: insertOne
1209        object: collection
1210        arguments:
1211          session: session0
1212          document:
1213            _id: 1
1214        result:
1215          insertedId: 1
1216      - name: commitTransaction
1217        object: session0
1218        result:
1219          errorLabelsContain: ["UnknownTransactionCommitResult"]
1220          errorLabelsOmit: ["RetryableWriteError", "TransientTransactionError"]
1221      - name: commitTransaction
1222        object: session0
1223
1224    expectations:
1225      - command_started_event:
1226          command:
1227            insert: *collection_name
1228            documents:
1229              - _id: 1
1230            ordered: true
1231            readConcern:
1232            lsid: session0
1233            txnNumber:
1234              $numberLong: "1"
1235            startTransaction: true
1236            autocommit: false
1237            writeConcern:
1238          command_name: insert
1239          database_name: *database_name
1240      - command_started_event:
1241          command:
1242            commitTransaction: 1
1243            lsid: session0
1244            txnNumber:
1245              $numberLong: "1"
1246            startTransaction:
1247            autocommit: false
1248            writeConcern:
1249              w: majority
1250            maxTimeMS: 60000
1251          command_name: commitTransaction
1252          database_name: admin
1253      - command_started_event:
1254          command:
1255            commitTransaction: 1
1256            lsid: session0
1257            txnNumber:
1258              $numberLong: "1"
1259            startTransaction:
1260            autocommit: false
1261            # commitTransaction applies w:majority on retries
1262            writeConcern: { w: majority, wtimeout: 10000 }
1263            maxTimeMS: 60000
1264          command_name: commitTransaction
1265          database_name: admin
1266
1267    outcome:
1268      collection:
1269        data:
1270          - _id: 1
1271