mongo 2.5.0.beta → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/mongo/address.rb +1 -1
  5. data/lib/mongo/address/unix.rb +1 -1
  6. data/lib/mongo/auth/user.rb +0 -5
  7. data/lib/mongo/auth/user/view.rb +4 -4
  8. data/lib/mongo/bulk_write.rb +60 -32
  9. data/lib/mongo/client.rb +44 -8
  10. data/lib/mongo/cluster.rb +14 -12
  11. data/lib/mongo/cluster/periodic_executor.rb +106 -0
  12. data/lib/mongo/cluster/{cursor_reaper.rb → reapers/cursor_reaper.rb} +5 -37
  13. data/lib/mongo/cluster/reapers/socket_reaper.rb +59 -0
  14. data/lib/mongo/collection.rb +9 -6
  15. data/lib/mongo/collection/view.rb +2 -2
  16. data/lib/mongo/collection/view/builder/aggregation.rb +2 -1
  17. data/lib/mongo/collection/view/builder/find_command.rb +1 -1
  18. data/lib/mongo/collection/view/change_stream.rb +14 -1
  19. data/lib/mongo/collection/view/map_reduce.rb +30 -13
  20. data/lib/mongo/collection/view/readable.rb +5 -5
  21. data/lib/mongo/collection/view/writable.rb +98 -51
  22. data/lib/mongo/error.rb +3 -0
  23. data/lib/mongo/error/invalid_txt_record.rb +27 -0
  24. data/lib/mongo/error/invalid_uri.rb +7 -6
  25. data/lib/mongo/error/mismatched_domain.rb +27 -0
  26. data/lib/mongo/error/no_srv_records.rb +26 -0
  27. data/lib/mongo/error/unsupported_features.rb +0 -18
  28. data/lib/mongo/index/view.rb +2 -2
  29. data/lib/mongo/operation.rb +1 -0
  30. data/lib/mongo/operation/causally_consistent.rb +33 -0
  31. data/lib/mongo/operation/commands.rb +2 -1
  32. data/lib/mongo/operation/commands/aggregate.rb +2 -7
  33. data/lib/mongo/operation/commands/count.rb +27 -0
  34. data/lib/mongo/operation/commands/distinct.rb +27 -0
  35. data/lib/mongo/operation/commands/find.rb +3 -1
  36. data/lib/mongo/operation/commands/map_reduce.rb +1 -0
  37. data/lib/mongo/operation/commands/parallel_scan.rb +1 -0
  38. data/lib/mongo/operation/specifiable.rb +12 -0
  39. data/lib/mongo/operation/uses_command_op_msg.rb +36 -5
  40. data/lib/mongo/operation/write.rb +0 -5
  41. data/lib/mongo/operation/write/bulk/bulkable.rb +4 -8
  42. data/lib/mongo/operation/write/bulk/mergable.rb +2 -0
  43. data/lib/mongo/operation/write/command/create_index.rb +19 -0
  44. data/lib/mongo/operation/write/command/create_user.rb +19 -0
  45. data/lib/mongo/operation/write/command/delete.rb +1 -2
  46. data/lib/mongo/operation/write/command/drop_index.rb +19 -0
  47. data/lib/mongo/operation/write/command/insert.rb +1 -2
  48. data/lib/mongo/operation/write/command/remove_user.rb +19 -0
  49. data/lib/mongo/operation/write/command/update.rb +1 -2
  50. data/lib/mongo/operation/write/command/update_user.rb +19 -0
  51. data/lib/mongo/operation/write/write_command_enabled.rb +1 -3
  52. data/lib/mongo/protocol/compressed.rb +2 -1
  53. data/lib/mongo/protocol/serializers.rb +6 -6
  54. data/lib/mongo/retryable.rb +48 -5
  55. data/lib/mongo/server.rb +15 -0
  56. data/lib/mongo/server/connection.rb +21 -1
  57. data/lib/mongo/server/connection_pool.rb +3 -0
  58. data/lib/mongo/server/connection_pool/queue.rb +50 -5
  59. data/lib/mongo/server/description.rb +11 -3
  60. data/lib/mongo/server/description/features.rb +26 -7
  61. data/lib/mongo/session.rb +133 -6
  62. data/lib/mongo/session/server_session.rb +30 -0
  63. data/lib/mongo/session/session_pool.rb +20 -20
  64. data/lib/mongo/uri.rb +88 -44
  65. data/lib/mongo/uri/srv_protocol.rb +158 -0
  66. data/lib/mongo/version.rb +1 -1
  67. data/lib/mongo/write_concern/normalizable.rb +12 -0
  68. data/mongo.gemspec +1 -2
  69. data/spec/mongo/address_spec.rb +12 -0
  70. data/spec/mongo/auth/user/view_spec.rb +1 -5
  71. data/spec/mongo/bulk_write_spec.rb +232 -401
  72. data/spec/mongo/change_stream_examples_spec.rb +150 -0
  73. data/spec/mongo/client_spec.rb +142 -2
  74. data/spec/mongo/cluster/cursor_reaper_spec.rb +0 -70
  75. data/spec/mongo/cluster/socket_reaper_spec.rb +32 -0
  76. data/spec/mongo/cluster_spec.rb +11 -7
  77. data/spec/mongo/collection/view/aggregation_spec.rb +46 -1
  78. data/spec/mongo/collection/view/builder/find_command_spec.rb +15 -0
  79. data/spec/mongo/collection/view/change_stream_spec.rb +79 -12
  80. data/spec/mongo/collection/view/map_reduce_spec.rb +120 -4
  81. data/spec/mongo/collection/view/readable_spec.rb +23 -5
  82. data/spec/mongo/collection_spec.rb +292 -102
  83. data/spec/mongo/command_monitoring_spec.rb +26 -32
  84. data/spec/mongo/crud_spec.rb +1 -1
  85. data/spec/mongo/cursor_spec.rb +2 -3
  86. data/spec/mongo/database_spec.rb +30 -14
  87. data/spec/mongo/dns_seedlist_discovery_spec.rb +94 -0
  88. data/spec/mongo/grid/fs_bucket_spec.rb +1 -1
  89. data/spec/mongo/grid/stream/write_spec.rb +1 -1
  90. data/spec/mongo/index/view_spec.rb +8 -46
  91. data/spec/mongo/operation/write/bulk/delete_spec.rb +2 -2
  92. data/spec/mongo/operation/write/bulk/insert_spec.rb +2 -10
  93. data/spec/mongo/operation/write/{create_index_spec.rb → command/create_index_spec.rb} +2 -6
  94. data/spec/mongo/operation/write/command/delete_spec.rb +35 -7
  95. data/spec/mongo/operation/write/{drop_index_spec.rb → command/drop_index_spec.rb} +1 -1
  96. data/spec/mongo/operation/write/command/insert_spec.rb +37 -6
  97. data/spec/mongo/operation/write/{remove_user_spec.rb → command/remove_user_spec.rb} +2 -6
  98. data/spec/mongo/operation/write/command/update_spec.rb +34 -7
  99. data/spec/mongo/operation/write/{update_user_spec.rb → command/update_user_spec.rb} +1 -1
  100. data/spec/mongo/operation/write/create_user_spec.rb +1 -1
  101. data/spec/mongo/operation/write/delete_spec.rb +1 -1
  102. data/spec/mongo/operation/write/insert_spec.rb +2 -10
  103. data/spec/mongo/operation/write/update_spec.rb +3 -15
  104. data/spec/mongo/retryable_spec.rb +1 -1
  105. data/spec/mongo/retryable_writes_spec.rb +815 -0
  106. data/spec/mongo/server/connection_pool/queue_spec.rb +35 -2
  107. data/spec/mongo/server/connection_pool_spec.rb +234 -1
  108. data/spec/mongo/server/connection_spec.rb +10 -6
  109. data/spec/mongo/server/description/features_spec.rb +51 -37
  110. data/spec/mongo/server/description_spec.rb +6 -3
  111. data/spec/mongo/server_spec.rb +87 -0
  112. data/spec/mongo/session/server_session_spec.rb +43 -0
  113. data/spec/mongo/session/session_pool_spec.rb +63 -27
  114. data/spec/mongo/session_spec.rb +247 -0
  115. data/spec/mongo/shell_examples_spec.rb +2 -2
  116. data/spec/mongo/uri/srv_protocol_spec.rb +933 -0
  117. data/spec/mongo/uri_spec.rb +42 -3
  118. data/spec/mongo/write_concern/acknowledged_spec.rb +11 -0
  119. data/spec/mongo/write_concern/unacknowledged_spec.rb +11 -0
  120. data/spec/spec_helper.rb +11 -25
  121. data/spec/support/authorization.rb +2 -1
  122. data/spec/support/connection_string.rb +8 -4
  123. data/spec/support/crud.rb +38 -24
  124. data/spec/support/crud/write.rb +30 -3
  125. data/spec/support/crud_tests/read/aggregate-out.yml +21 -0
  126. data/spec/support/crud_tests/write/bulkWrite-arrayFilters.yml +44 -0
  127. data/spec/support/crud_tests/write/findOneAndUpdate-arrayFilters.yml +1 -1
  128. data/spec/support/crud_tests/write/insertMany.yml +1 -3
  129. data/spec/support/crud_tests/write/replaceOne.yml +1 -1
  130. data/spec/support/crud_tests/write/updateMany-arrayFilters.yml +1 -1
  131. data/spec/support/crud_tests/write/updateOne-arrayFilters.yml +1 -1
  132. data/spec/support/dns_seedlist_discovery_tests/longer-parent-in-return.yml +11 -0
  133. data/spec/support/dns_seedlist_discovery_tests/misformatted-option.yml +5 -0
  134. data/spec/support/dns_seedlist_discovery_tests/no-results.yml +5 -0
  135. data/spec/support/dns_seedlist_discovery_tests/not-enough-parts.yml +5 -0
  136. data/spec/support/dns_seedlist_discovery_tests/one-result-default-port.yml +10 -0
  137. data/spec/support/dns_seedlist_discovery_tests/one-txt-record-multiple-strings.yml +10 -0
  138. data/spec/support/dns_seedlist_discovery_tests/one-txt-record.yml +11 -0
  139. data/spec/support/dns_seedlist_discovery_tests/parent-part-mismatch1.yml +5 -0
  140. data/spec/support/dns_seedlist_discovery_tests/parent-part-mismatch2.yml +5 -0
  141. data/spec/support/dns_seedlist_discovery_tests/parent-part-mismatch3.yml +5 -0
  142. data/spec/support/dns_seedlist_discovery_tests/parent-part-mismatch4.yml +5 -0
  143. data/spec/support/dns_seedlist_discovery_tests/parent-part-mismatch5.yml +5 -0
  144. data/spec/support/dns_seedlist_discovery_tests/returned-parent-too-short.yml +5 -0
  145. data/spec/support/dns_seedlist_discovery_tests/returned-parent-wrong.yml +5 -0
  146. data/spec/support/dns_seedlist_discovery_tests/two-results-default-port.yml +11 -0
  147. data/spec/support/dns_seedlist_discovery_tests/two-results-nonstandard-port.yml +11 -0
  148. data/spec/support/dns_seedlist_discovery_tests/two-txt-records.yml +5 -0
  149. data/spec/support/dns_seedlist_discovery_tests/txt-record-not-allowed-option.yml +5 -0
  150. data/spec/support/dns_seedlist_discovery_tests/txt-record-with-overridden-ssl-option.yml +11 -0
  151. data/spec/support/dns_seedlist_discovery_tests/txt-record-with-overridden-uri-option.yml +11 -0
  152. data/spec/support/dns_seedlist_discovery_tests/txt-record-with-unallowed-option.yml +5 -0
  153. data/spec/support/dns_seedlist_discovery_tests/uri-with-port.yml +5 -0
  154. data/spec/support/dns_seedlist_discovery_tests/uri-with-two-hosts.yml +5 -0
  155. data/spec/support/retryable_writes_tests/bulkWrite.yml +305 -0
  156. data/spec/support/retryable_writes_tests/deleteOne.yml +51 -0
  157. data/spec/support/retryable_writes_tests/findOneAndDelete.yml +52 -0
  158. data/spec/support/retryable_writes_tests/findOneAndReplace.yml +57 -0
  159. data/spec/support/retryable_writes_tests/findOneAndUpdate.yml +56 -0
  160. data/spec/support/retryable_writes_tests/insertMany.yml +72 -0
  161. data/spec/support/retryable_writes_tests/insertOne.yml +55 -0
  162. data/spec/support/retryable_writes_tests/replaceOne.yml +60 -0
  163. data/spec/support/retryable_writes_tests/updateOne.yml +120 -0
  164. data/spec/support/shared/session.rb +525 -24
  165. metadata +437 -350
  166. metadata.gz.sig +0 -0
  167. data/lib/mongo/operation/commands/user_query.rb +0 -72
  168. data/lib/mongo/operation/write/create_index.rb +0 -67
  169. data/lib/mongo/operation/write/create_user.rb +0 -50
  170. data/lib/mongo/operation/write/drop_index.rb +0 -63
  171. data/lib/mongo/operation/write/remove_user.rb +0 -48
  172. data/lib/mongo/operation/write/update_user.rb +0 -50
@@ -1,7 +1,7 @@
1
1
  data:
2
2
  - {_id: 1, y: [{b: 3}, {b: 1}]}
3
3
  - {_id: 2, y: [{b: 0}, {b: 1}]}
4
- minServerVersion: '3.6'
4
+ minServerVersion: '3.5.6'
5
5
 
6
6
  tests:
7
7
  -
@@ -13,9 +13,7 @@ tests:
13
13
 
14
14
  outcome:
15
15
  result:
16
- insertedIds:
17
- - 2
18
- - 3
16
+ insertedIds: { 0: 2, 1: 3 }
19
17
  collection:
20
18
  data:
21
19
  - {_id: 1, x: 11}
@@ -10,7 +10,7 @@ tests:
10
10
  operation:
11
11
  name: "replaceOne"
12
12
  arguments:
13
- filter:
13
+ filter:
14
14
  _id: {$gt: 1}
15
15
  replacement: {x: 111}
16
16
 
@@ -1,7 +1,7 @@
1
1
  data:
2
2
  - {_id: 1, y: [{b: 3}, {b: 1}]}
3
3
  - {_id: 2, y: [{b: 0}, {b: 1}]}
4
- minServerVersion: '3.6'
4
+ minServerVersion: '3.5.6'
5
5
 
6
6
  tests:
7
7
  -
@@ -2,7 +2,7 @@ data:
2
2
  - {_id: 1, y: [{b: 3}, {b: 1}]}
3
3
  - {_id: 2, y: [{b: 0}, {b: 1}]}
4
4
  - {_id: 3, y: [{b: 5, c: [{d: 2}, {d: 1}] }]}
5
- minServerVersion: '3.6'
5
+ minServerVersion: '3.5.6'
6
6
 
7
7
  tests:
8
8
  -
@@ -0,0 +1,11 @@
1
+ uri: "mongodb+srv://test18.test.build.10gen.cc/?replicaSet=repl0"
2
+ seeds:
3
+ - localhost.sub.test.build.10gen.cc:27017
4
+ hosts:
5
+ - localhost:27017
6
+ - localhost:27018
7
+ - localhost:27019
8
+ options:
9
+ replicaSet: repl0
10
+ ssl: true
11
+ comment: Is correct, as returned host name shared the URI root "test.build.10gen.cc".
@@ -0,0 +1,5 @@
1
+ uri: "mongodb+srv://test8.test.build.10gen.cc/"
2
+ seeds: []
3
+ hosts: []
4
+ error: true
5
+ comment: Should fail because the options in the TXT record are incorrectly formatted (misses value).
@@ -0,0 +1,5 @@
1
+ uri: "mongodb+srv://test4.test.build.10gen.cc/"
2
+ seeds: []
3
+ hosts: []
4
+ error: true
5
+ comment: Should fail because no SRV records are present for this URI.
@@ -0,0 +1,5 @@
1
+ uri: "mongodb+srv://10gen.cc/"
2
+ seeds: []
3
+ hosts: []
4
+ error: true
5
+ comment: Should fail because host in URI does not have {hostname}, {domainname} and {tld}.
@@ -0,0 +1,10 @@
1
+ uri: "mongodb+srv://test3.test.build.10gen.cc/?replicaSet=repl0"
2
+ seeds:
3
+ - localhost.test.build.10gen.cc:27017
4
+ hosts:
5
+ - localhost:27017
6
+ - localhost:27018
7
+ - localhost:27019
8
+ options:
9
+ replicaSet: repl0
10
+ ssl: true
@@ -0,0 +1,10 @@
1
+ uri: "mongodb+srv://test11.test.build.10gen.cc/"
2
+ seeds:
3
+ - localhost.test.build.10gen.cc:27017
4
+ hosts:
5
+ - localhost:27017
6
+ - localhost:27018
7
+ - localhost:27019
8
+ options:
9
+ replicaSet: repl0
10
+ ssl: true
@@ -0,0 +1,11 @@
1
+ uri: "mongodb+srv://test5.test.build.10gen.cc/"
2
+ seeds:
3
+ - localhost.test.build.10gen.cc:27017
4
+ hosts:
5
+ - localhost:27017
6
+ - localhost:27018
7
+ - localhost:27019
8
+ options:
9
+ replicaSet: repl0
10
+ authSource: thisDB
11
+ ssl: true
@@ -0,0 +1,5 @@
1
+ uri: "mongodb+srv://test14.test.build.10gen.cc/"
2
+ seeds: []
3
+ hosts: []
4
+ error: true
5
+ comment: Should fail because returned host name's part "not-test" mismatches URI parent part "test".
@@ -0,0 +1,5 @@
1
+ uri: "mongodb+srv://test15.test.build.10gen.cc/"
2
+ seeds: []
3
+ hosts: []
4
+ error: true
5
+ comment: Should fail because returned host name's part "not-build" mismatches URI parent part "build".
@@ -0,0 +1,5 @@
1
+ uri: "mongodb+srv://test16.test.build.10gen.cc/"
2
+ seeds: []
3
+ hosts: []
4
+ error: true
5
+ comment: Should fail because returned host name's part "not-10gen" mismatches URI parent part "10gen".
@@ -0,0 +1,5 @@
1
+ uri: "mongodb+srv://test17.test.build.10gen.cc/"
2
+ seeds: []
3
+ hosts: []
4
+ error: true
5
+ comment: Should fail because returned host name's TLD "not-cc" mismatches URI TLD "cc".
@@ -0,0 +1,5 @@
1
+ uri: "mongodb+srv://test19.test.build.10gen.cc/"
2
+ seeds: []
3
+ hosts: []
4
+ error: true
5
+ comment: Should fail because one of the returned host names' domain name parts "evil" mismatches "test".
@@ -0,0 +1,5 @@
1
+ uri: "mongodb+srv://test13.test.build.10gen.cc/"
2
+ seeds: []
3
+ hosts: []
4
+ error: true
5
+ comment: Should fail because returned host name's parent (build.10gen.cc) misses "test."
@@ -0,0 +1,5 @@
1
+ uri: "mongodb+srv://test12.test.build.10gen.cc/"
2
+ seeds: []
3
+ hosts: []
4
+ error: true
5
+ comment: Should fail because returned host name is too short and mismatches a parent.
@@ -0,0 +1,11 @@
1
+ uri: "mongodb+srv://test1.test.build.10gen.cc/?replicaSet=repl0"
2
+ seeds:
3
+ - localhost.test.build.10gen.cc:27017
4
+ - localhost.test.build.10gen.cc:27018
5
+ hosts:
6
+ - localhost:27017
7
+ - localhost:27018
8
+ - localhost:27019
9
+ options:
10
+ replicaSet: repl0
11
+ ssl: true
@@ -0,0 +1,11 @@
1
+ uri: "mongodb+srv://test2.test.build.10gen.cc/?replicaSet=repl0"
2
+ seeds:
3
+ - localhost.test.build.10gen.cc:27018
4
+ - localhost.test.build.10gen.cc:27019
5
+ hosts:
6
+ - localhost:27017
7
+ - localhost:27018
8
+ - localhost:27019
9
+ options:
10
+ replicaSet: repl0
11
+ ssl: true
@@ -0,0 +1,5 @@
1
+ uri: "mongodb+srv://test6.test.build.10gen.cc/"
2
+ seeds: []
3
+ hosts: []
4
+ error: true
5
+ comment: Should fail because there are two TXT records.
@@ -0,0 +1,5 @@
1
+ uri: "mongodb+srv://test10.test.build.10gen.cc/?replicaSet=repl0"
2
+ seeds: []
3
+ hosts: []
4
+ error: true
5
+ comment: Should fail because socketTimeoutMS is not an allowed option.
@@ -0,0 +1,11 @@
1
+ uri: "mongodb+srv://test5.test.build.10gen.cc/?ssl=false"
2
+ seeds:
3
+ - localhost.test.build.10gen.cc:27017
4
+ hosts:
5
+ - localhost:27017
6
+ - localhost:27018
7
+ - localhost:27019
8
+ options:
9
+ replicaSet: repl0
10
+ authSource: thisDB
11
+ ssl: false
@@ -0,0 +1,11 @@
1
+ uri: "mongodb+srv://test5.test.build.10gen.cc/?authSource=otherDB"
2
+ seeds:
3
+ - localhost.test.build.10gen.cc:27017
4
+ hosts:
5
+ - localhost:27017
6
+ - localhost:27018
7
+ - localhost:27019
8
+ options:
9
+ replicaSet: repl0
10
+ authSource: otherDB
11
+ ssl: true
@@ -0,0 +1,5 @@
1
+ uri: "mongodb+srv://test7.test.build.10gen.cc/"
2
+ seeds: []
3
+ hosts: []
4
+ error: true
5
+ comment: Should fail because "ssl" is not an allowed option.
@@ -0,0 +1,5 @@
1
+ uri: "mongodb+srv://test5.test.build.10gen.cc:8123/?replicaSet=repl0"
2
+ seeds: []
3
+ hosts: []
4
+ error: true
5
+ comment: Should fail because the mongodb+srv URI includes a port.
@@ -0,0 +1,5 @@
1
+ uri: "mongodb+srv://test5.test.build.10gen.cc,test6.test.build.10gen.cc/?replicaSet=repl0"
2
+ seeds: []
3
+ hosts: []
4
+ error: true
5
+ comment: Should fail because the mongodb+srv URI includes two host names.
@@ -0,0 +1,305 @@
1
+ data:
2
+ - { _id: 1, x: 11 }
3
+
4
+ minServerVersion: '3.6'
5
+
6
+ tests:
7
+ -
8
+ description: "First command is retried"
9
+ failPoint:
10
+ mode: { times: 1 }
11
+ operation:
12
+ name: "bulkWrite"
13
+ arguments:
14
+ requests:
15
+ -
16
+ name: "insertOne"
17
+ arguments:
18
+ document: { _id: 2, x: 22 }
19
+ -
20
+ name: "updateOne"
21
+ arguments:
22
+ filter: { _id: 2 }
23
+ update: { $inc: { x : 1 }}
24
+ -
25
+ name: "deleteOne"
26
+ arguments:
27
+ filter: { _id: 1 }
28
+ options: { ordered: true }
29
+ outcome:
30
+ result:
31
+ deletedCount: 1
32
+ insertedIds: { 0: 2 }
33
+ matchedCount: 1
34
+ modifiedCount: 1
35
+ upsertedCount: 0
36
+ upsertedIds: { }
37
+ collection:
38
+ data:
39
+ - { _id: 2, x: 23 }
40
+ -
41
+ # Write operations in this ordered batch are intentionally sequenced so
42
+ # that each write command consists of a single statement, which will
43
+ # fail on the first attempt and succeed on the second, retry attempt.
44
+ description: "All commands are retried"
45
+ failPoint:
46
+ mode: { times: 7 }
47
+ operation:
48
+ name: "bulkWrite"
49
+ arguments:
50
+ requests:
51
+ -
52
+ name: "insertOne"
53
+ arguments:
54
+ document: { _id: 2, x: 22 }
55
+ -
56
+ name: "updateOne"
57
+ arguments:
58
+ filter: { _id: 2 }
59
+ update: { $inc: { x : 1 }}
60
+ -
61
+ name: "insertOne"
62
+ arguments:
63
+ document: { _id: 3, x: 33 }
64
+ -
65
+ name: "updateOne"
66
+ arguments:
67
+ filter: { _id: 4, x: 44 }
68
+ update: { $inc: { x : 1 }}
69
+ upsert: true
70
+ -
71
+ name: "insertOne"
72
+ arguments:
73
+ document: { _id: 5, x: 55 }
74
+ -
75
+ name: "replaceOne"
76
+ arguments:
77
+ filter: { _id: 3 }
78
+ replacement: { _id: 3, x: 333 }
79
+ -
80
+ name: "deleteOne"
81
+ arguments:
82
+ filter: { _id: 1 }
83
+ options: { ordered: true }
84
+ outcome:
85
+ result:
86
+ deletedCount: 1
87
+ insertedIds: { 0: 2, 2: 3, 4: 5 }
88
+ matchedCount: 2
89
+ modifiedCount: 2
90
+ upsertedCount: 1
91
+ upsertedIds: { 3: 4 }
92
+ collection:
93
+ data:
94
+ - { _id: 2, x: 23 }
95
+ - { _id: 3, x: 333 }
96
+ - { _id: 4, x: 45 }
97
+ - { _id: 5, x: 55 }
98
+ -
99
+ description: "Both commands are retried after their first statement fails"
100
+ failPoint:
101
+ mode: { times: 2 }
102
+ operation:
103
+ name: "bulkWrite"
104
+ arguments:
105
+ requests:
106
+ -
107
+ name: "insertOne"
108
+ arguments:
109
+ document: { _id: 2, x: 22 }
110
+ -
111
+ name: "updateOne"
112
+ arguments:
113
+ filter: { _id: 1 }
114
+ update: { $inc: { x : 1 }}
115
+ -
116
+ name: "updateOne"
117
+ arguments:
118
+ filter: { _id: 2 }
119
+ update: { $inc: { x : 1 }}
120
+ options: { ordered: true }
121
+ outcome:
122
+ result:
123
+ deletedCount: 0
124
+ insertedIds: { 0: 2 }
125
+ matchedCount: 2
126
+ modifiedCount: 2
127
+ upsertedCount: 0
128
+ upsertedIds: { }
129
+ collection:
130
+ data:
131
+ - { _id: 1, x: 12 }
132
+ - { _id: 2, x: 23 }
133
+ -
134
+ description: "Second command is retried after its second statement fails"
135
+ failPoint:
136
+ mode: { skip: 2 }
137
+ operation:
138
+ name: "bulkWrite"
139
+ arguments:
140
+ requests:
141
+ -
142
+ name: "insertOne"
143
+ arguments:
144
+ document: { _id: 2, x: 22 }
145
+ -
146
+ name: "updateOne"
147
+ arguments:
148
+ filter: { _id: 1 }
149
+ update: { $inc: { x : 1 }}
150
+ -
151
+ name: "updateOne"
152
+ arguments:
153
+ filter: { _id: 2 }
154
+ update: { $inc: { x : 1 }}
155
+ options: { ordered: true }
156
+ outcome:
157
+ result:
158
+ deletedCount: 0
159
+ insertedIds: { 0: 2 }
160
+ matchedCount: 2
161
+ modifiedCount: 2
162
+ upsertedCount: 0
163
+ upsertedIds: { }
164
+ collection:
165
+ data:
166
+ - { _id: 1, x: 12 }
167
+ - { _id: 2, x: 23 }
168
+ -
169
+ description: "BulkWrite with unordered execution"
170
+ failPoint:
171
+ mode: { times: 1 }
172
+ operation:
173
+ name: "bulkWrite"
174
+ arguments:
175
+ requests:
176
+ -
177
+ name: "insertOne"
178
+ arguments:
179
+ document: { _id: 2, x: 22 }
180
+ -
181
+ name: "insertOne"
182
+ arguments:
183
+ document: { _id: 3, x: 33 }
184
+ options: { ordered: false }
185
+ outcome:
186
+ result:
187
+ deletedCount: 0
188
+ insertedIds: { 0: 2, 1: 3 }
189
+ matchedCount: 0
190
+ modifiedCount: 0
191
+ upsertedCount: 0
192
+ upsertedIds: { }
193
+ collection:
194
+ data:
195
+ - { _id: 1, x: 11 }
196
+ - { _id: 2, x: 22 }
197
+ - { _id: 3, x: 33 }
198
+ -
199
+ description: "First insertOne is never committed"
200
+ failPoint:
201
+ mode: { times: 2 }
202
+ data: { failBeforeCommitExceptionCode: 1 }
203
+ operation:
204
+ name: "bulkWrite"
205
+ arguments:
206
+ requests:
207
+ -
208
+ name: "insertOne"
209
+ arguments:
210
+ document: { _id: 2, x: 22 }
211
+ -
212
+ name: "updateOne"
213
+ arguments:
214
+ filter: { _id: 2 }
215
+ update: { $inc: { x : 1 }}
216
+ -
217
+ name: "deleteOne"
218
+ arguments:
219
+ filter: { _id: 1 }
220
+ options: { ordered: true }
221
+ outcome:
222
+ error: true
223
+ result:
224
+ deletedCount: 0
225
+ insertedIds: { }
226
+ matchedCount: 0
227
+ modifiedCount: 0
228
+ upsertedCount: 0
229
+ upsertedIds: { }
230
+ collection:
231
+ data:
232
+ - { _id: 1, x: 11 }
233
+ -
234
+ description: "Second updateOne is never committed"
235
+ failPoint:
236
+ mode: { skip: 1 }
237
+ data: { failBeforeCommitExceptionCode: 1 }
238
+ operation:
239
+ name: "bulkWrite"
240
+ arguments:
241
+ requests:
242
+ -
243
+ name: "insertOne"
244
+ arguments:
245
+ document: { _id: 2, x: 22 }
246
+ -
247
+ name: "updateOne"
248
+ arguments:
249
+ filter: { _id: 2 }
250
+ update: { $inc: { x : 1 }}
251
+ -
252
+ name: "deleteOne"
253
+ arguments:
254
+ filter: { _id: 1 }
255
+ options: { ordered: true }
256
+ outcome:
257
+ error: true
258
+ result:
259
+ deletedCount: 0
260
+ insertedIds: { 0: 2 }
261
+ matchedCount: 0
262
+ modifiedCount: 0
263
+ upsertedCount: 0
264
+ upsertedIds: { }
265
+ collection:
266
+ data:
267
+ - { _id: 1, x: 11 }
268
+ - { _id: 2, x: 22 }
269
+ -
270
+ description: "Third updateOne is never committed"
271
+ failPoint:
272
+ mode: { skip: 2 }
273
+ data: { failBeforeCommitExceptionCode: 1 }
274
+ operation:
275
+ name: "bulkWrite"
276
+ arguments:
277
+ requests:
278
+ -
279
+ name: "updateOne"
280
+ arguments:
281
+ filter: { _id: 1 }
282
+ update: { $inc: { x : 1 }}
283
+ -
284
+ name: "insertOne"
285
+ arguments:
286
+ document: { _id: 2, x: 22 }
287
+ -
288
+ name: "updateOne"
289
+ arguments:
290
+ filter: { _id: 2 }
291
+ update: { $inc: { x : 1 }}
292
+ options: { ordered: true }
293
+ outcome:
294
+ error: true
295
+ result:
296
+ deletedCount: 0
297
+ insertedIds: { 0: 2 }
298
+ matchedCount: 1
299
+ modifiedCount: 1
300
+ upsertedCount: 0
301
+ upsertedIds: { }
302
+ collection:
303
+ data:
304
+ - { _id: 1, x: 12 }
305
+ - { _id: 2, x: 22 }