Debian Codegraph @

testdata/transactions/legacy/transaction-options.yml

raw symbols SCIP
1 runOn:
2 -
3 minServerVersion: "4.0"
4 topology: ["replicaset"]
5 -
6 minServerVersion: "4.1.8"
7 topology: ["sharded"]
8
9 database_name: &database_name "transaction-tests"
10 collection_name: &collection_name "test"
11
12 data: []
13
14 tests:
15 - description: no transaction options set
16
17 operations: &commitAbortOperations
18 - name: startTransaction
19 object: session0
20 - name: insertOne
21 object: collection
22 arguments:
23 session: session0
24 document:
25 _id: 1
26 result:
27 insertedId: 1
28 - name: commitTransaction
29 object: session0
30 # Now test abort.
31 - name: startTransaction
32 object: session0
33 - name: insertOne
34 object: collection
35 arguments:
36 session: session0
37 document:
38 _id: 2
39 result:
40 insertedId: 2
41 - name: abortTransaction
42 object: session0
43
44 expectations:
45 - command_started_event:
46 command:
47 insert: *collection_name
48 documents:
49 - _id: 1
50 ordered: true
51 lsid: session0
52 txnNumber:
53 $numberLong: "1"
54 startTransaction: true
55 autocommit: false
56 readConcern:
57 writeConcern:
58 maxTimeMS:
59 command_name: insert
60 database_name: *database_name
61 - command_started_event:
62 command:
63 commitTransaction: 1
64 lsid: session0
65 txnNumber:
66 $numberLong: "1"
67 startTransaction:
68 autocommit: false
69 readConcern:
70 writeConcern:
71 maxTimeMS:
72 command_name: commitTransaction
73 database_name: admin
74 - command_started_event:
75 command:
76 insert: *collection_name
77 documents:
78 - _id: 2
79 ordered: true
80 lsid: session0
81 txnNumber:
82 $numberLong: "2"
83 startTransaction: true
84 autocommit: false
85 readConcern:
86 afterClusterTime: 42
87 writeConcern:
88 maxTimeMS:
89 command_name: insert
90 database_name: *database_name
91 - command_started_event:
92 command:
93 abortTransaction: 1
94 lsid: session0
95 txnNumber:
96 $numberLong: "2"
97 startTransaction:
98 autocommit: false
99 readConcern:
100 writeConcern:
101 maxTimeMS:
102 command_name: abortTransaction
103 database_name: admin
104
105 outcome: &outcome
106 collection:
107 data:
108 - _id: 1
109
110 - description: transaction options inherited from client
111
112 clientOptions:
113 w: 1
114 readConcernLevel: local
115
116 operations: *commitAbortOperations
117
118 expectations:
119 - command_started_event:
120 command:
121 insert: *collection_name
122 documents:
123 - _id: 1
124 ordered: true
125 lsid: session0
126 txnNumber:
127 $numberLong: "1"
128 startTransaction: true
129 autocommit: false
130 readConcern:
131 level: local
132 writeConcern:
133 maxTimeMS:
134 command_name: insert
135 database_name: *database_name
136 - command_started_event:
137 command:
138 commitTransaction: 1
139 lsid: session0
140 txnNumber:
141 $numberLong: "1"
142 startTransaction:
143 autocommit: false
144 readConcern:
145 writeConcern:
146 w: 1
147 maxTimeMS:
148 command_name: commitTransaction
149 database_name: admin
150 - command_started_event:
151 command:
152 insert: *collection_name
153 documents:
154 - _id: 2
155 ordered: true
156 lsid: session0
157 txnNumber:
158 $numberLong: "2"
159 startTransaction: true
160 autocommit: false
161 readConcern:
162 level: local
163 afterClusterTime: 42
164 writeConcern:
165 maxTimeMS:
166 command_name: insert
167 database_name: *database_name
168 - command_started_event:
169 command:
170 abortTransaction: 1
171 lsid: session0
172 txnNumber:
173 $numberLong: "2"
174 startTransaction:
175 autocommit: false
176 readConcern:
177 writeConcern:
178 w: 1
179 maxTimeMS:
180 command_name: abortTransaction
181 database_name: admin
182
183 outcome: *outcome
184
185 - description: transaction options inherited from defaultTransactionOptions
186
187 sessionOptions:
188 session0:
189 defaultTransactionOptions:
190 readConcern:
191 level: majority
192 writeConcern:
193 w: 1
194 maxCommitTimeMS: 60000
195
196 operations: *commitAbortOperations
197
198 expectations:
199 - command_started_event:
200 command:
201 insert: *collection_name
202 documents:
203 - _id: 1
204 ordered: true
205 lsid: session0
206 txnNumber:
207 $numberLong: "1"
208 startTransaction: true
209 autocommit: false
210 readConcern:
211 level: majority
212 writeConcern:
213 command_name: insert
214 database_name: *database_name
215 - command_started_event:
216 command:
217 commitTransaction: 1
218 lsid: session0
219 txnNumber:
220 $numberLong: "1"
221 startTransaction:
222 autocommit: false
223 readConcern:
224 writeConcern:
225 w: 1
226 maxTimeMS: 60000
227 command_name: commitTransaction
228 database_name: admin
229 - command_started_event:
230 command:
231 insert: *collection_name
232 documents:
233 - _id: 2
234 ordered: true
235 lsid: session0
236 txnNumber:
237 $numberLong: "2"
238 startTransaction: true
239 autocommit: false
240 readConcern:
241 level: majority
242 afterClusterTime: 42
243 writeConcern:
244 command_name: insert
245 database_name: *database_name
246 - command_started_event:
247 command:
248 abortTransaction: 1
249 lsid: session0
250 txnNumber:
251 $numberLong: "2"
252 startTransaction:
253 autocommit: false
254 readConcern:
255 writeConcern:
256 w: 1
257 command_name: abortTransaction
258 database_name: admin
259
260 outcome: *outcome
261
262 - description: startTransaction options override defaults
263
264 clientOptions:
265 readConcernLevel: local
266 w: 1
267
268 sessionOptions:
269 session0:
270 defaultTransactionOptions:
271 readConcern:
272 level: snapshot
273 writeConcern:
274 w: 1
275 maxCommitTimeMS: 30000
276
277 operations:
278 - name: startTransaction
279 object: session0
280 arguments:
281 options:
282 readConcern:
283 level: majority
284 writeConcern:
285 w: majority
286 maxCommitTimeMS: 60000
287 - name: insertOne
288 object: collection
289 arguments:
290 session: session0
291 document:
292 _id: 1
293 result:
294 insertedId: 1
295 - name: commitTransaction
296 object: session0
297 - name: startTransaction
298 object: session0
299 arguments:
300 options:
301 readConcern:
302 level: majority
303 writeConcern:
304 w: majority
305 - name: insertOne
306 object: collection
307 arguments:
308 session: session0
309 document:
310 _id: 2
311 result:
312 insertedId: 2
313 - name: abortTransaction
314 object: session0
315
316 expectations:
317 - command_started_event:
318 command:
319 insert: *collection_name
320 documents:
321 - _id: 1
322 ordered: true
323 lsid: session0
324 txnNumber:
325 $numberLong: "1"
326 startTransaction: true
327 autocommit: false
328 readConcern:
329 level: majority
330 writeConcern:
331 maxTimeMS:
332 command_name: insert
333 database_name: *database_name
334 - command_started_event:
335 command:
336 commitTransaction: 1
337 lsid: session0
338 txnNumber:
339 $numberLong: "1"
340 startTransaction:
341 autocommit: false
342 readConcern:
343 writeConcern:
344 w: majority
345 maxTimeMS: 60000
346 command_name: commitTransaction
347 database_name: admin
348 - command_started_event:
349 command:
350 insert: *collection_name
351 documents:
352 - _id: 2
353 ordered: true
354 lsid: session0
355 txnNumber:
356 $numberLong: "2"
357 startTransaction: true
358 autocommit: false
359 readConcern:
360 level: majority
361 afterClusterTime: 42
362 writeConcern:
363 maxTimeMS:
364 command_name: insert
365 database_name: *database_name
366 - command_started_event:
367 command:
368 abortTransaction: 1
369 lsid: session0
370 txnNumber:
371 $numberLong: "2"
372 startTransaction:
373 autocommit: false
374 readConcern:
375 writeConcern:
376 w: majority
377 maxTimeMS:
378 command_name: abortTransaction
379 database_name: admin
380
381 outcome: *outcome
382
383 - description: defaultTransactionOptions override client options
384
385 clientOptions:
386 readConcernLevel: local
387 w: 1
388
389 sessionOptions:
390 session0:
391 defaultTransactionOptions:
392 readConcern:
393 level: majority
394 writeConcern:
395 w: majority
396 maxCommitTimeMS: 60000
397
398 operations: *commitAbortOperations
399
400 expectations:
401 - command_started_event:
402 command:
403 insert: *collection_name
404 documents:
405 - _id: 1
406 ordered: true
407 lsid: session0
408 txnNumber:
409 $numberLong: "1"
410 startTransaction: true
411 autocommit: false
412 readConcern:
413 level: majority
414 writeConcern:
415 maxTimeMS:
416 command_name: insert
417 database_name: *database_name
418 - command_started_event:
419 command:
420 commitTransaction: 1
421 lsid: session0
422 txnNumber:
423 $numberLong: "1"
424 startTransaction:
425 autocommit: false
426 readConcern:
427 writeConcern:
428 w: majority
429 maxTimeMS: 60000
430 command_name: commitTransaction
431 database_name: admin
432 - command_started_event:
433 command:
434 insert: *collection_name
435 documents:
436 - _id: 2
437 ordered: true
438 lsid: session0
439 txnNumber:
440 $numberLong: "2"
441 startTransaction: true
442 autocommit: false
443 readConcern:
444 level: majority
445 afterClusterTime: 42
446 writeConcern:
447 maxTimeMS:
448 command_name: insert
449 database_name: *database_name
450 - command_started_event:
451 command:
452 abortTransaction: 1
453 lsid: session0
454 txnNumber:
455 $numberLong: "2"
456 startTransaction:
457 autocommit: false
458 readConcern:
459 writeConcern:
460 w: majority
461 maxTimeMS:
462 command_name: abortTransaction
463 database_name: admin
464
465 outcome: *outcome
466
467 - description: readConcern local in defaultTransactionOptions
468
469 clientOptions:
470 w: 1
471
472 sessionOptions:
473 session0:
474 defaultTransactionOptions:
475 readConcern:
476 level: local
477
478 operations: *commitAbortOperations
479
480 expectations:
481 - command_started_event:
482 command:
483 insert: *collection_name
484 documents:
485 - _id: 1
486 ordered: true
487 lsid: session0
488 txnNumber:
489 $numberLong: "1"
490 startTransaction: true
491 autocommit: false
492 readConcern:
493 level: local
494 writeConcern:
495 command_name: insert
496 database_name: *database_name
497 - command_started_event:
498 command:
499 commitTransaction: 1
500 lsid: session0
501 txnNumber:
502 $numberLong: "1"
503 startTransaction:
504 autocommit: false
505 readConcern:
506 writeConcern:
507 w: 1
508 command_name: commitTransaction
509 database_name: admin
510 - command_started_event:
511 command:
512 insert: *collection_name
513 documents:
514 - _id: 2
515 ordered: true
516 lsid: session0
517 txnNumber:
518 $numberLong: "2"
519 startTransaction: true
520 autocommit: false
521 readConcern:
522 level: local
523 afterClusterTime: 42
524 writeConcern:
525 command_name: insert
526 database_name: *database_name
527 - command_started_event:
528 command:
529 abortTransaction: 1
530 lsid: session0
531 txnNumber:
532 $numberLong: "2"
533 startTransaction:
534 autocommit: false
535 readConcern:
536 writeConcern:
537 w: 1
538 command_name: abortTransaction
539 database_name: admin
540
541 outcome: *outcome
542
543 - description: client writeConcern ignored for bulk
544
545 clientOptions:
546 w: majority
547
548 operations:
549 - name: startTransaction
550 object: session0
551 arguments:
552 options:
553 writeConcern:
554 w: 1
555 - name: bulkWrite
556 object: collection
557 arguments:
558 requests:
559 - name: insertOne
560 arguments:
561 document: {_id: 1}
562 session: session0
563 result:
564 deletedCount: 0
565 insertedCount: 1
566 insertedIds: {0: 1}
567 matchedCount: 0
568 modifiedCount: 0
569 upsertedCount: 0
570 upsertedIds: {}
571 - name: commitTransaction
572 object: session0
573
574 expectations:
575 - command_started_event:
576 command:
577 insert: *collection_name
578 documents:
579 - _id: 1
580 ordered: true
581 readConcern:
582 lsid: session0
583 txnNumber:
584 $numberLong: "1"
585 startTransaction: true
586 autocommit: false
587 # No writeConcern.
588 writeConcern:
589 command_name: insert
590 database_name: *database_name
591 - command_started_event:
592 command:
593 commitTransaction: 1
594 lsid: session0
595 txnNumber:
596 $numberLong: "1"
597 startTransaction:
598 autocommit: false
599 writeConcern:
600 w: 1
601 command_name: commitTransaction
602 database_name: admin
603
604 outcome: *outcome
605
606 - description: readPreference inherited from client
607
608 clientOptions:
609 readPreference: secondary
610
611 operations:
612 - name: startTransaction
613 object: session0
614 - name: insertOne
615 object: collection
616 arguments:
617 session: session0
618 document:
619 _id: 1
620 result:
621 insertedId: 1
622 - name: find
623 object: collection
624 arguments:
625 session: session0
626 filter:
627 _id: 1
628 result:
629 errorContains: read preference in a transaction must be primary
630 - name: commitTransaction
631 object: session0
632
633 expectations:
634 - command_started_event:
635 command:
636 insert: *collection_name
637 documents:
638 - _id: 1
639 ordered: true
640 lsid: session0
641 txnNumber:
642 $numberLong: "1"
643 startTransaction: true
644 autocommit: false
645 readConcern:
646 writeConcern:
647 command_name: insert
648 database_name: *database_name
649 - command_started_event:
650 command:
651 commitTransaction: 1
652 lsid: session0
653 txnNumber:
654 $numberLong: "1"
655 startTransaction:
656 autocommit: false
657 readConcern:
658 writeConcern:
659 command_name: commitTransaction
660 database_name: admin
661
662 outcome:
663 collection:
664 data:
665 - _id: 1
666
667 - description: readPreference inherited from defaultTransactionOptions
668
669 clientOptions:
670 readPreference: primary
671
672 sessionOptions:
673 session0:
674 defaultTransactionOptions:
675 readPreference:
676 mode: Secondary
677
678 operations:
679 - name: startTransaction
680 object: session0
681 - name: insertOne
682 object: collection
683 arguments:
684 session: session0
685 document:
686 _id: 1
687 result:
688 insertedId: 1
689 - name: find
690 object: collection
691 arguments:
692 session: session0
693 filter:
694 _id: 1
695 result:
696 errorContains: read preference in a transaction must be primary
697 - name: commitTransaction
698 object: session0
699
700 expectations:
701 - command_started_event:
702 command:
703 insert: *collection_name
704 documents:
705 - _id: 1
706 ordered: true
707 lsid: session0
708 txnNumber:
709 $numberLong: "1"
710 startTransaction: true
711 autocommit: false
712 readConcern:
713 writeConcern:
714 command_name: insert
715 database_name: *database_name
716 - command_started_event:
717 command:
718 commitTransaction: 1
719 lsid: session0
720 txnNumber:
721 $numberLong: "1"
722 startTransaction:
723 autocommit: false
724 readConcern:
725 writeConcern:
726 command_name: commitTransaction
727 database_name: admin
728
729 outcome:
730 collection:
731 data:
732 - _id: 1
733
734 - description: startTransaction overrides readPreference
735
736 clientOptions:
737 readPreference: primary
738
739 sessionOptions:
740 session0:
741 defaultTransactionOptions:
742 readPreference:
743 mode: Primary
744
745 operations:
746 - name: startTransaction
747 object: session0
748 arguments:
749 options:
750 readPreference:
751 mode: Secondary
752 - name: insertOne
753 object: collection
754 arguments:
755 session: session0
756 document:
757 _id: 1
758 result:
759 insertedId: 1
760 - name: find
761 object: collection
762 arguments:
763 session: session0
764 filter:
765 _id: 1
766 result:
767 errorContains: read preference in a transaction must be primary
768 - name: commitTransaction
769 object: session0
770
771 expectations:
772 - command_started_event:
773 command:
774 insert: *collection_name
775 documents:
776 - _id: 1
777 ordered: true
778 lsid: session0
779 txnNumber:
780 $numberLong: "1"
781 startTransaction: true
782 autocommit: false
783 readConcern:
784 writeConcern:
785 command_name: insert
786 database_name: *database_name
787 - command_started_event:
788 command:
789 commitTransaction: 1
790 lsid: session0
791 txnNumber:
792 $numberLong: "1"
793 startTransaction:
794 autocommit: false
795 readConcern:
796 writeConcern:
797 command_name: commitTransaction
798 database_name: admin
799
800 outcome:
801 collection:
802 data:
803 - _id: 1