...
1description: "driver-sessions-dirty-session-errors"
2
3schemaVersion: "1.0"
4
5runOnRequirements:
6 - minServerVersion: "4.0"
7 topologies: [ replicaset ]
8 - minServerVersion: "4.1.8"
9 # Tests depend on retryable writes, which require a replica set
10 topologies: [ sharded-replicaset ]
11
12createEntities:
13 - client:
14 id: &client0 client0
15 useMultipleMongoses: false
16 observeEvents: [ commandStartedEvent ]
17 - database:
18 id: &database0 database0
19 client: *client0
20 databaseName: &database0Name session-tests
21 - collection:
22 id: &collection0 collection0
23 database: *database0
24 collectionName: &collection0Name test
25 - session:
26 id: &session0 session0
27 client: *client0
28
29initialData:
30 - collectionName: *collection0Name
31 databaseName: *database0Name
32 documents:
33 - { _id: 1 }
34
35tests:
36 - description: "Dirty explicit session is discarded (insert)"
37 operations:
38 - name: failPoint
39 object: testRunner
40 arguments:
41 client: *client0
42 failPoint:
43 configureFailPoint: failCommand
44 mode: { times: 1 }
45 data:
46 failCommands: [ insert ]
47 closeConnection: true
48 - name: assertSessionNotDirty
49 object: testRunner
50 arguments:
51 session: *session0
52 - name: insertOne
53 object: *collection0
54 arguments:
55 session: *session0
56 document: { _id: 2 }
57 expectResult: { $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 2 } } }
58 - name: assertSessionDirty
59 object: testRunner
60 arguments:
61 session: *session0
62 - name: insertOne
63 object: *collection0
64 arguments:
65 session: *session0
66 document: { _id: 3 }
67 expectResult: { $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 3 } } }
68 - name: assertSessionDirty
69 object: testRunner
70 arguments:
71 session: *session0
72 - name: endSession
73 object: *session0
74 - &find_with_implicit_session
75 name: find
76 object: *collection0
77 arguments:
78 filter: { _id: -1 }
79 expectResult: []
80 - name: assertDifferentLsidOnLastTwoCommands
81 object: testRunner
82 arguments:
83 client: *client0
84 expectEvents:
85 - client: *client0
86 events:
87 - commandStartedEvent: &insert_attempt
88 command:
89 insert: *collection0Name
90 documents:
91 - { _id: 2 }
92 ordered: true
93 lsid: { $$sessionLsid: *session0 }
94 txnNumber: 1
95 commandName: insert
96 databaseName: *database0Name
97 - commandStartedEvent: *insert_attempt
98 - commandStartedEvent:
99 command:
100 insert: *collection0Name
101 documents:
102 - { _id: 3 }
103 ordered: true
104 lsid: { $$sessionLsid: *session0 }
105 txnNumber: 2
106 commandName: insert
107 databaseName: *database0Name
108 - commandStartedEvent: &find_with_implicit_session_event
109 command:
110 find: *collection0Name
111 filter: { _id: -1 }
112 # There is no explicit session to use with $$sessionLsid, so
113 # just assert an arbitrary lsid document
114 lsid: { $$type: object }
115 commandName: find
116 databaseName: *database0Name
117 outcome:
118 - collectionName: *collection0Name
119 databaseName: *database0Name
120 documents:
121 - { _id: 1 }
122 - { _id: 2 }
123 - { _id: 3 }
124
125 - description: "Dirty explicit session is discarded (findAndModify)"
126 operations:
127 - name: failPoint
128 object: testRunner
129 arguments:
130 client: *client0
131 failPoint:
132 configureFailPoint: failCommand
133 mode: { times: 1 }
134 data:
135 failCommands: [ findAndModify ]
136 closeConnection: true
137 - name: assertSessionNotDirty
138 object: testRunner
139 arguments:
140 session: *session0
141 - name: findOneAndUpdate
142 object: *collection0
143 arguments:
144 session: *session0
145 filter: { _id: 1 }
146 update: { $inc: { x: 1 } }
147 returnDocument: Before
148 expectResult: { _id: 1 }
149 - name: assertSessionDirty
150 object: testRunner
151 arguments:
152 session: *session0
153 - name: endSession
154 object: *session0
155 - *find_with_implicit_session
156 - name: assertDifferentLsidOnLastTwoCommands
157 object: testRunner
158 arguments:
159 client: *client0
160 expectEvents:
161 - client: *client0
162 events:
163 - commandStartedEvent: &findAndModify_attempt
164 command:
165 findAndModify: *collection0Name
166 query: { _id: 1 }
167 update: { $inc: { x: 1 } }
168 new: false
169 lsid: { $$sessionLsid: *session0 }
170 txnNumber: 1
171 readConcern: { $$exists: false }
172 writeConcern: { $$exists: false }
173 commandName: findAndModify
174 databaseName: *database0Name
175 - commandStartedEvent: *findAndModify_attempt
176 - commandStartedEvent: *find_with_implicit_session_event
177 outcome:
178 - collectionName: *collection0Name
179 databaseName: *database0Name
180 documents:
181 - { _id: 1, x: 1 }
182
183 - description: "Dirty implicit session is discarded (insert)"
184 operations:
185 - name: failPoint
186 object: testRunner
187 arguments:
188 client: *client0
189 failPoint:
190 configureFailPoint: failCommand
191 mode: { times: 1 }
192 data:
193 failCommands: [ insert ]
194 closeConnection: true
195 - name: insertOne
196 object: *collection0
197 arguments:
198 document: { _id: 2 }
199 expectResult: { $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 2 } } }
200 - *find_with_implicit_session
201 - name: assertDifferentLsidOnLastTwoCommands
202 object: testRunner
203 arguments:
204 client: *client0
205 expectEvents:
206 - client: *client0
207 events:
208 - commandStartedEvent: &insert_attempt
209 command:
210 insert: *collection0Name
211 documents:
212 - { _id: 2 }
213 ordered: true
214 lsid: { $$type: object }
215 txnNumber: 1
216 commandName: insert
217 databaseName: *database0Name
218 - commandStartedEvent: *insert_attempt
219 - commandStartedEvent: *find_with_implicit_session_event
220 outcome:
221 - collectionName: *collection0Name
222 databaseName: *database0Name
223 documents:
224 - { _id: 1 }
225 - { _id: 2 }
226
227 - description: "Dirty implicit session is discarded (findAndModify)"
228 operations:
229 - name: failPoint
230 object: testRunner
231 arguments:
232 client: *client0
233 failPoint:
234 configureFailPoint: failCommand
235 mode: { times: 1 }
236 data:
237 failCommands: [ findAndModify ]
238 closeConnection: true
239 - name: findOneAndUpdate
240 object: *collection0
241 arguments:
242 filter: { _id: 1 }
243 update: { $inc: { x: 1 } }
244 returnDocument: Before
245 expectResult: { _id: 1 }
246 - *find_with_implicit_session
247 - name: assertDifferentLsidOnLastTwoCommands
248 object: testRunner
249 arguments:
250 client: *client0
251 expectEvents:
252 - client: *client0
253 events:
254 - commandStartedEvent: &findAndModify_attempt
255 command:
256 findAndModify: *collection0Name
257 query: { _id: 1 }
258 update: { $inc: { x: 1 } }
259 new: false
260 lsid: { $$type: object }
261 txnNumber: 1
262 readConcern: { $$exists: false }
263 writeConcern: { $$exists: false }
264 commandName: findAndModify
265 databaseName: *database0Name
266 - commandStartedEvent: *findAndModify_attempt
267 - commandStartedEvent: *find_with_implicit_session_event
268 outcome:
269 - collectionName: *collection0Name
270 databaseName: *database0Name
271 documents:
272 - { _id: 1, x: 1 }
273
274 - description: "Dirty implicit session is discarded (read returning cursor)"
275 operations:
276 - name: failPoint
277 object: testRunner
278 arguments:
279 client: *client0
280 failPoint:
281 configureFailPoint: failCommand
282 mode: { times: 1 }
283 data:
284 failCommands: [ aggregate ]
285 closeConnection: true
286 - name: aggregate
287 object: *collection0
288 arguments:
289 pipeline: [ { $project: { _id: 1 } } ]
290 expectResult: [ { _id: 1 } ]
291 - *find_with_implicit_session
292 - name: assertDifferentLsidOnLastTwoCommands
293 object: testRunner
294 arguments:
295 client: *client0
296 expectEvents:
297 - client: *client0
298 events:
299 - commandStartedEvent: &aggregate_attempt
300 command:
301 aggregate: *collection0Name
302 pipeline: [ { $project: { _id: 1 } } ]
303 lsid: { $$type: object }
304 commandName: aggregate
305 databaseName: *database0Name
306 - commandStartedEvent: *aggregate_attempt
307 - commandStartedEvent: *find_with_implicit_session_event
308 outcome:
309 - collectionName: *collection0Name
310 databaseName: *database0Name
311 documents:
312 - { _id: 1 }
313
314 - description: "Dirty implicit session is discarded (read not returning cursor)"
315 operations:
316 - name: failPoint
317 object: testRunner
318 arguments:
319 client: *client0
320 failPoint:
321 configureFailPoint: failCommand
322 mode: { times: 1 }
323 data:
324 failCommands: [ aggregate ]
325 closeConnection: true
326 - name: countDocuments
327 object: *collection0
328 arguments:
329 filter: {}
330 expectResult: 1
331 - *find_with_implicit_session
332 - name: assertDifferentLsidOnLastTwoCommands
333 object: testRunner
334 arguments:
335 client: *client0
336 expectEvents:
337 - client: *client0
338 events:
339 - commandStartedEvent: &countDocuments_attempt
340 command:
341 aggregate: *collection0Name
342 pipeline: [ { $match: {} }, { $group: { _id: 1, n: { $sum: 1 } } } ]
343 lsid: { $$type: object }
344 commandName: aggregate
345 databaseName: *database0Name
346 - commandStartedEvent: *countDocuments_attempt
347 - commandStartedEvent: *find_with_implicit_session_event
348 outcome:
349 - collectionName: *collection0Name
350 databaseName: *database0Name
351 documents:
352 - { _id: 1 }
View as plain text