...
1runOn:
2 -
3 minServerVersion: "4.0"
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
14tests:
15 -
16 description: callback succeeds after multiple connection errors
17 failPoint:
18 configureFailPoint: failCommand
19 mode: { times: 2 }
20 data:
21 failCommands: ["insert"]
22 closeConnection: true
23 operations:
24 -
25 name: withTransaction
26 object: session0
27 arguments:
28 callback:
29 operations:
30 -
31 # We do not assert the result here, as insertOne will fail for
32 # the first two executions of the callback before ultimately
33 # succeeding and returning a result. Asserting the state of the
34 # output collection after the test is sufficient.
35 name: insertOne
36 object: collection
37 arguments:
38 session: session0
39 document: { _id: 1 }
40 expectations:
41 -
42 command_started_event:
43 command:
44 insert: *collection_name
45 documents:
46 - { _id: 1 }
47 ordered: true
48 lsid: session0
49 txnNumber: { $numberLong: "1" }
50 startTransaction: true
51 autocommit: false
52 # omitted fields
53 readConcern: ~
54 writeConcern: ~
55 command_name: insert
56 database_name: *database_name
57 -
58 command_started_event:
59 command:
60 abortTransaction: 1
61 lsid: session0
62 txnNumber: { $numberLong: "1" }
63 autocommit: false
64 # omitted fields
65 readConcern: ~
66 startTransaction: ~
67 writeConcern: ~
68 command_name: abortTransaction
69 database_name: admin
70 -
71 command_started_event:
72 command:
73 insert: *collection_name
74 documents:
75 - { _id: 1 }
76 ordered: true
77 lsid: session0
78 # second transaction will be causally consistent with the first
79 readConcern: { afterClusterTime: 42 }
80 # txnNumber is incremented when retrying the transaction
81 txnNumber: { $numberLong: "2" }
82 startTransaction: true
83 autocommit: false
84 # omitted fields
85 writeConcern: ~
86 command_name: insert
87 database_name: *database_name
88 -
89 command_started_event:
90 command:
91 abortTransaction: 1
92 lsid: session0
93 txnNumber: { $numberLong: "2" }
94 autocommit: false
95 # omitted fields
96 readConcern: ~
97 startTransaction: ~
98 writeConcern: ~
99 command_name: abortTransaction
100 database_name: admin
101 -
102 command_started_event:
103 command:
104 insert: *collection_name
105 documents:
106 - { _id: 1 }
107 ordered: true
108 lsid: session0
109 # third transaction will be causally consistent with the second
110 readConcern: { afterClusterTime: 42 }
111 # txnNumber is incremented when retrying the transaction
112 txnNumber: { $numberLong: "3" }
113 startTransaction: true
114 autocommit: false
115 # omitted fields
116 writeConcern: ~
117 command_name: insert
118 database_name: *database_name
119 -
120 command_started_event:
121 command:
122 commitTransaction: 1
123 lsid: session0
124 txnNumber: { $numberLong: "3" }
125 autocommit: false
126 # omitted fields
127 readConcern: ~
128 startTransaction: ~
129 writeConcern: ~
130 command_name: commitTransaction
131 database_name: admin
132 outcome:
133 collection:
134 data:
135 - { _id: 1 }
136 -
137 description: callback is not retried after non-transient error (DuplicateKeyError)
138 useMultipleMongoses: true
139 operations:
140 -
141 name: withTransaction
142 object: session0
143 arguments:
144 callback:
145 operations:
146 -
147 name: insertOne
148 object: collection
149 arguments:
150 session: session0
151 document: { _id: 1 }
152 result:
153 insertedId: 1
154 -
155 name: insertOne
156 object: collection
157 arguments:
158 session: session0
159 document: { _id: 1 }
160 result:
161 errorLabelsOmit: ["TransientTransactionError", "UnknownTransactionCommitResult"]
162 result:
163 errorLabelsOmit: ["TransientTransactionError", "UnknownTransactionCommitResult"]
164 # DuplicateKey error code included in the bulk write error message
165 # returned by the server
166 errorContains: E11000
167 expectations:
168 -
169 command_started_event:
170 command:
171 insert: *collection_name
172 documents:
173 - { _id: 1 }
174 ordered: true
175 lsid: session0
176 txnNumber: { $numberLong: "1" }
177 startTransaction: true
178 autocommit: false
179 # omitted fields
180 readConcern: ~
181 writeConcern: ~
182 command_name: insert
183 database_name: *database_name
184 -
185 command_started_event:
186 command:
187 insert: *collection_name
188 documents:
189 - { _id: 1 }
190 ordered: true
191 lsid: session0
192 txnNumber: { $numberLong: "1" }
193 autocommit: false
194 # omitted fields
195 readConcern: ~
196 startTransaction: ~
197 writeConcern: ~
198 command_name: insert
199 database_name: *database_name
200 -
201 command_started_event:
202 command:
203 abortTransaction: 1
204 lsid: session0
205 txnNumber: { $numberLong: "1" }
206 autocommit: false
207 # omitted fields
208 readConcern: ~
209 startTransaction: ~
210 writeConcern: ~
211 command_name: abortTransaction
212 database_name: admin
213 outcome:
214 collection:
215 data: []
View as plain text