...
1runOn:
2 -
3 minServerVersion: "4.1.6"
4 topology: ["replicaset"]
5 -
6 minServerVersion: "4.1.8"
7 topology: ["sharded"]
8
9database_name: &database_name "withTransaction-tests"
10collection_name: &collection_name "test"
11
12data: []
13
14# These tests use error codes where the TransientTransactionError label will be
15# applied to the error response for commitTransaction. This will cause the
16# entire transaction to be retried instead of commitTransaction.
17#
18# See: https://github.com/mongodb/mongo/blob/r4.1.6/src/mongo/db/handle_request_response.cpp
19tests:
20 -
21 description: transaction is retried after commitTransaction TransientTransactionError (PreparedTransactionInProgress)
22 failPoint:
23 configureFailPoint: failCommand
24 mode: { times: 2 }
25 data:
26 failCommands: ["commitTransaction"]
27 errorCode: 267 # PreparedTransactionInProgress
28 closeConnection: false
29 operations:
30 -
31 name: withTransaction
32 object: session0
33 arguments:
34 callback:
35 operations:
36 -
37 name: insertOne
38 object: collection
39 arguments:
40 session: session0
41 document: { _id: 1 }
42 result:
43 insertedId: 1
44 expectations:
45 -
46 command_started_event:
47 command:
48 insert: *collection_name
49 documents:
50 - { _id: 1 }
51 ordered: true
52 lsid: session0
53 txnNumber: { $numberLong: "1" }
54 startTransaction: true
55 autocommit: false
56 # omitted fields
57 readConcern: ~
58 writeConcern: ~
59 command_name: insert
60 database_name: *database_name
61 -
62 command_started_event:
63 command:
64 commitTransaction: 1
65 lsid: session0
66 txnNumber: { $numberLong: "1" }
67 autocommit: false
68 # omitted fields
69 readConcern: ~
70 startTransaction: ~
71 writeConcern: ~
72 command_name: commitTransaction
73 database_name: admin
74 -
75 command_started_event:
76 command:
77 insert: *collection_name
78 documents:
79 - { _id: 1 }
80 ordered: true
81 lsid: session0
82 # second transaction will be causally consistent with the first
83 readConcern: { afterClusterTime: 42 }
84 # txnNumber is incremented when retrying the transaction
85 txnNumber: { $numberLong: "2" }
86 startTransaction: true
87 autocommit: false
88 # omitted fields
89 writeConcern: ~
90 command_name: insert
91 database_name: *database_name
92 -
93 command_started_event:
94 command:
95 commitTransaction: 1
96 lsid: session0
97 txnNumber: { $numberLong: "2" }
98 autocommit: false
99 # omitted fields
100 readConcern: ~
101 startTransaction: ~
102 writeConcern: ~
103 command_name: commitTransaction
104 database_name: admin
105 -
106 command_started_event:
107 command:
108 insert: *collection_name
109 documents:
110 - { _id: 1 }
111 ordered: true
112 lsid: session0
113 # third transaction will be causally consistent with the second
114 readConcern: { afterClusterTime: 42 }
115 # txnNumber is incremented when retrying the transaction
116 txnNumber: { $numberLong: "3" }
117 startTransaction: true
118 autocommit: false
119 # omitted fields
120 writeConcern: ~
121 command_name: insert
122 database_name: *database_name
123 -
124 command_started_event:
125 command:
126 commitTransaction: 1
127 lsid: session0
128 txnNumber: { $numberLong: "3" }
129 autocommit: false
130 # omitted fields
131 readConcern: ~
132 startTransaction: ~
133 writeConcern: ~
134 command_name: commitTransaction
135 database_name: admin
136 outcome:
137 collection:
138 data:
139 - { _id: 1 }
View as plain text