mongo 2.9.2 → 2.10.0.rc0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) 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.rb +1 -0
  5. data/lib/mongo/auth/user/view.rb +4 -4
  6. data/lib/mongo/bulk_write.rb +14 -8
  7. data/lib/mongo/bulk_write/result.rb +1 -1
  8. data/lib/mongo/bulk_write/result_combiner.rb +2 -2
  9. data/lib/mongo/bulk_write/transformable.rb +17 -9
  10. data/lib/mongo/client.rb +107 -16
  11. data/lib/mongo/cluster.rb +47 -25
  12. data/lib/mongo/cluster/topology/replica_set_no_primary.rb +1 -1
  13. data/lib/mongo/cluster_time.rb +139 -0
  14. data/lib/mongo/collection.rb +84 -25
  15. data/lib/mongo/collection/view.rb +7 -3
  16. data/lib/mongo/collection/view/aggregation.rb +4 -4
  17. data/lib/mongo/collection/view/builder/aggregation.rb +31 -6
  18. data/lib/mongo/collection/view/builder/find_command.rb +4 -1
  19. data/lib/mongo/collection/view/builder/map_reduce.rb +4 -1
  20. data/lib/mongo/collection/view/change_stream.rb +54 -66
  21. data/lib/mongo/collection/view/iterable.rb +2 -2
  22. data/lib/mongo/collection/view/map_reduce.rb +6 -4
  23. data/lib/mongo/collection/view/readable.rb +36 -16
  24. data/lib/mongo/collection/view/writable.rb +68 -22
  25. data/lib/mongo/cursor.rb +87 -20
  26. data/lib/mongo/database.rb +47 -43
  27. data/lib/mongo/database/view.rb +54 -11
  28. data/lib/mongo/error.rb +13 -4
  29. data/lib/mongo/error/invalid_write_concern.rb +2 -2
  30. data/lib/mongo/error/operation_failure.rb +65 -11
  31. data/lib/mongo/error/parser.rb +41 -8
  32. data/lib/mongo/grid/fs_bucket.rb +26 -6
  33. data/lib/mongo/grid/stream/read.rb +9 -2
  34. data/lib/mongo/grid/stream/write.rb +21 -5
  35. data/lib/mongo/index/view.rb +3 -3
  36. data/lib/mongo/lint.rb +10 -3
  37. data/lib/mongo/operation.rb +2 -0
  38. data/lib/mongo/operation/aggregate/result.rb +19 -6
  39. data/lib/mongo/operation/collections_info.rb +1 -1
  40. data/lib/mongo/operation/get_more/result.rb +9 -0
  41. data/lib/mongo/operation/list_collections/command.rb +1 -3
  42. data/lib/mongo/operation/list_collections/op_msg.rb +1 -2
  43. data/lib/mongo/operation/parallel_scan/command.rb +4 -1
  44. data/lib/mongo/operation/parallel_scan/op_msg.rb +4 -1
  45. data/lib/mongo/operation/result.rb +27 -4
  46. data/lib/mongo/operation/shared/executable.rb +19 -5
  47. data/lib/mongo/operation/shared/executable_no_validate.rb +1 -2
  48. data/lib/mongo/operation/shared/executable_transaction_label.rb +0 -9
  49. data/lib/mongo/operation/shared/polymorphic_result.rb +9 -1
  50. data/lib/mongo/operation/shared/result/aggregatable.rb +2 -2
  51. data/lib/mongo/operation/shared/sessions_supported.rb +42 -32
  52. data/lib/mongo/operation/shared/specifiable.rb +40 -0
  53. data/lib/mongo/operation/shared/unpinnable.rb +39 -0
  54. data/lib/mongo/operation/shared/write.rb +1 -1
  55. data/lib/mongo/protocol/update.rb +6 -2
  56. data/lib/mongo/retryable.rb +79 -39
  57. data/lib/mongo/server/connection.rb +10 -3
  58. data/lib/mongo/server/description.rb +25 -1
  59. data/lib/mongo/server/monitor/connection.rb +1 -1
  60. data/lib/mongo/server_selector.rb +10 -0
  61. data/lib/mongo/server_selector/selectable.rb +172 -32
  62. data/lib/mongo/session.rb +654 -581
  63. data/lib/mongo/session/session_pool.rb +1 -1
  64. data/lib/mongo/socket.rb +7 -28
  65. data/lib/mongo/socket/ssl.rb +26 -1
  66. data/lib/mongo/socket/tcp.rb +3 -0
  67. data/lib/mongo/socket/unix.rb +3 -0
  68. data/lib/mongo/uri.rb +112 -265
  69. data/lib/mongo/uri/srv_protocol.rb +4 -1
  70. data/lib/mongo/version.rb +1 -1
  71. data/lib/mongo/write_concern.rb +10 -29
  72. data/lib/mongo/write_concern/acknowledged.rb +12 -0
  73. data/lib/mongo/write_concern/base.rb +17 -13
  74. data/lib/mongo/write_concern/unacknowledged.rb +12 -0
  75. data/spec/atlas/atlas_connectivity_spec.rb +7 -37
  76. data/spec/atlas/operations_spec.rb +25 -0
  77. data/spec/integration/change_stream_examples_spec.rb +45 -31
  78. data/spec/integration/change_stream_spec.rb +305 -5
  79. data/spec/integration/client_spec.rb +44 -0
  80. data/spec/integration/command_monitoring_spec.rb +1 -0
  81. data/spec/integration/command_spec.rb +7 -1
  82. data/spec/integration/mmapv1_spec.rb +28 -0
  83. data/spec/integration/mongos_pinning_spec.rb +34 -0
  84. data/spec/integration/operation_failure_code_spec.rb +2 -2
  85. data/spec/integration/{read_concern.rb → read_concern_spec.rb} +7 -1
  86. data/spec/integration/read_preference_spec.rb +485 -0
  87. data/spec/integration/retryable_writes_spec.rb +8 -19
  88. data/spec/integration/sdam_error_handling_spec.rb +1 -1
  89. data/spec/integration/sdam_events_spec.rb +2 -2
  90. data/spec/integration/server_description_spec.rb +14 -17
  91. data/spec/integration/server_selector_spec.rb +7 -3
  92. data/spec/integration/server_spec.rb +48 -0
  93. data/spec/integration/ssl_uri_options_spec.rb +1 -1
  94. data/spec/integration/step_down_spec.rb +10 -4
  95. data/spec/integration/transactions_examples_spec.rb +11 -10
  96. data/spec/lite_spec_helper.rb +19 -16
  97. data/spec/mongo/auth/scram/negotiation_spec.rb +11 -8
  98. data/spec/mongo/bulk_write/ordered_combiner_spec.rb +6 -6
  99. data/spec/mongo/bulk_write/unordered_combiner_spec.rb +4 -4
  100. data/spec/mongo/bulk_write_spec.rb +12 -2
  101. data/spec/mongo/client_construction_spec.rb +160 -8
  102. data/spec/mongo/client_spec.rb +5 -4
  103. data/spec/mongo/cluster_spec.rb +6 -6
  104. data/spec/mongo/cluster_time_spec.rb +148 -0
  105. data/spec/mongo/collection/view/aggregation_spec.rb +34 -15
  106. data/spec/mongo/collection/view/change_stream_spec.rb +62 -3
  107. data/spec/mongo/collection/view/map_reduce_spec.rb +7 -5
  108. data/spec/mongo/collection/view/readable_spec.rb +4 -4
  109. data/spec/mongo/collection_spec.rb +331 -14
  110. data/spec/mongo/cursor_spec.rb +117 -5
  111. data/spec/mongo/database_spec.rb +240 -8
  112. data/spec/mongo/error/operation_failure_spec.rb +47 -1
  113. data/spec/mongo/error/parser_spec.rb +160 -23
  114. data/spec/mongo/operation/insert/bulk_spec.rb +2 -1
  115. data/spec/mongo/operation/result_spec.rb +27 -0
  116. data/spec/mongo/operation/update/bulk_spec.rb +1 -0
  117. data/spec/mongo/retryable_spec.rb +2 -0
  118. data/spec/mongo/server/app_metadata_spec.rb +2 -2
  119. data/spec/mongo/server/connection_spec.rb +13 -17
  120. data/spec/mongo/server/monitor/connection_spec.rb +13 -10
  121. data/spec/mongo/server_selector_spec.rb +34 -2
  122. data/spec/mongo/session/session_pool_spec.rb +14 -3
  123. data/spec/mongo/session_spec.rb +3 -3
  124. data/spec/mongo/session_transaction_spec.rb +4 -3
  125. data/spec/mongo/socket/ssl_spec.rb +19 -5
  126. data/spec/mongo/socket_spec.rb +1 -62
  127. data/spec/mongo/uri/srv_protocol_spec.rb +14 -20
  128. data/spec/mongo/uri_option_parsing_spec.rb +94 -8
  129. data/spec/mongo/uri_spec.rb +23 -10
  130. data/spec/mongo/write_concern_spec.rb +56 -3
  131. data/spec/spec_tests/change_streams_spec.rb +2 -1
  132. data/spec/spec_tests/cmap_spec.rb +1 -1
  133. data/spec/spec_tests/crud_spec.rb +12 -2
  134. data/spec/spec_tests/data/change_streams/change-streams-errors.yml +24 -1
  135. data/spec/spec_tests/data/change_streams/change-streams.yml +172 -3
  136. data/spec/spec_tests/data/command_monitoring/bulkWrite.yml +1 -1
  137. data/spec/spec_tests/data/command_monitoring/updateMany.yml +0 -2
  138. data/spec/spec_tests/data/command_monitoring/updateOne.yml +0 -5
  139. data/spec/spec_tests/data/crud/read/aggregate-out.yml +0 -6
  140. data/spec/spec_tests/data/crud/read/count-empty.yml +29 -0
  141. data/spec/spec_tests/data/crud/write/bulkWrite-arrayFilters.yml +1 -0
  142. data/spec/spec_tests/data/crud/write/bulkWrite-collation.yml +101 -0
  143. data/spec/spec_tests/data/crud/write/bulkWrite.yml +401 -0
  144. data/spec/spec_tests/data/crud/write/insertMany.yml +58 -2
  145. data/spec/spec_tests/data/crud/write/updateMany-arrayFilters.yml +3 -0
  146. data/spec/spec_tests/data/crud/write/updateOne-arrayFilters.yml +6 -1
  147. data/spec/spec_tests/data/crud_v2/aggregate-merge.yml +103 -0
  148. data/spec/spec_tests/data/crud_v2/aggregate-out-readConcern.yml +110 -0
  149. data/spec/spec_tests/data/crud_v2/bulkWrite-arrayFilters.yml +81 -0
  150. data/spec/spec_tests/data/crud_v2/db-aggregate.yml +38 -0
  151. data/spec/spec_tests/data/crud_v2/updateWithPipelines.yml +92 -0
  152. data/spec/spec_tests/data/retryable_writes/insertOne-serverErrors.yml +2 -2
  153. data/spec/spec_tests/data/transactions/abort.yml +3 -0
  154. data/spec/spec_tests/data/transactions/bulk.yml +3 -8
  155. data/spec/spec_tests/data/transactions/causal-consistency.yml +3 -8
  156. data/spec/spec_tests/data/transactions/commit.yml +3 -1
  157. data/spec/spec_tests/data/transactions/count.yml +3 -0
  158. data/spec/spec_tests/data/transactions/delete.yml +3 -0
  159. data/spec/spec_tests/data/transactions/error-labels.yml +4 -1
  160. data/spec/spec_tests/data/transactions/errors-client.yml +56 -0
  161. data/spec/spec_tests/data/transactions/errors.yml +3 -0
  162. data/spec/spec_tests/data/transactions/findOneAndDelete.yml +3 -0
  163. data/spec/spec_tests/data/transactions/findOneAndReplace.yml +3 -0
  164. data/spec/spec_tests/data/transactions/findOneAndUpdate.yml +3 -0
  165. data/spec/spec_tests/data/transactions/insert.yml +3 -0
  166. data/spec/spec_tests/data/transactions/isolation.yml +3 -0
  167. data/spec/spec_tests/data/transactions/mongos-pin-auto.yml +1671 -0
  168. data/spec/spec_tests/data/transactions/mongos-recovery-token.yml +347 -0
  169. data/spec/spec_tests/data/transactions/pin-mongos.yml +557 -0
  170. data/spec/spec_tests/data/transactions/read-concern.yml +3 -0
  171. data/spec/spec_tests/data/transactions/read-pref.yml +3 -0
  172. data/spec/spec_tests/data/transactions/reads.yml +3 -0
  173. data/spec/spec_tests/data/transactions/retryable-abort.yml +5 -2
  174. data/spec/spec_tests/data/transactions/retryable-commit.yml +4 -1
  175. data/spec/spec_tests/data/transactions/retryable-writes.yml +3 -0
  176. data/spec/spec_tests/data/transactions/run-command.yml +3 -0
  177. data/spec/spec_tests/data/transactions/transaction-options.yml +6 -0
  178. data/spec/spec_tests/data/transactions/update.yml +3 -8
  179. data/spec/spec_tests/data/transactions/write-concern.yml +348 -38
  180. data/spec/spec_tests/data/transactions_api/callback-aborts.yml +6 -0
  181. data/spec/spec_tests/data/transactions_api/callback-commits.yml +5 -0
  182. data/spec/spec_tests/data/transactions_api/callback-retry.yml +7 -2
  183. data/spec/spec_tests/data/transactions_api/commit-retry.yml +70 -15
  184. data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror-4.2.yml +3 -0
  185. data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror.yml +3 -0
  186. data/spec/spec_tests/data/transactions_api/commit-writeconcernerror.yml +59 -109
  187. data/spec/spec_tests/data/transactions_api/commit.yml +5 -0
  188. data/spec/spec_tests/data/transactions_api/transaction-options.yml +10 -0
  189. data/spec/spec_tests/retryable_reads_spec.rb +5 -2
  190. data/spec/spec_tests/retryable_writes_spec.rb +5 -2
  191. data/spec/spec_tests/sdam_monitoring_spec.rb +3 -3
  192. data/spec/spec_tests/sdam_spec.rb +2 -2
  193. data/spec/spec_tests/transactions_api_spec.rb +1 -67
  194. data/spec/spec_tests/transactions_spec.rb +2 -66
  195. data/spec/support/authorization.rb +4 -0
  196. data/spec/support/change_streams.rb +30 -10
  197. data/spec/support/change_streams/operation.rb +27 -0
  198. data/spec/support/client_registry.rb +44 -25
  199. data/spec/support/cluster_config.rb +25 -14
  200. data/spec/support/cluster_tools.rb +32 -10
  201. data/spec/support/command_monitoring.rb +1 -1
  202. data/spec/support/common_shortcuts.rb +30 -0
  203. data/spec/support/connection_string.rb +8 -3
  204. data/spec/support/constraints.rb +34 -0
  205. data/spec/support/crud.rb +31 -16
  206. data/spec/support/crud/context.rb +23 -0
  207. data/spec/support/crud/operation.rb +311 -14
  208. data/spec/support/crud/spec.rb +2 -1
  209. data/spec/support/crud/test.rb +24 -27
  210. data/spec/support/crud/test_base.rb +22 -0
  211. data/spec/support/crud/verifier.rb +15 -1
  212. data/spec/support/event_subscriber.rb +12 -0
  213. data/spec/support/sdam_formatter_integration.rb +12 -6
  214. data/spec/support/shared/server_selector.rb +10 -0
  215. data/spec/support/shared/session.rb +13 -12
  216. data/spec/support/spec_config.rb +32 -22
  217. data/spec/support/spec_setup.rb +2 -2
  218. data/spec/support/transactions.rb +87 -0
  219. data/spec/support/transactions/context.rb +33 -0
  220. data/spec/support/transactions/operation.rb +99 -349
  221. data/spec/support/transactions/spec.rb +1 -3
  222. data/spec/support/transactions/test.rb +110 -49
  223. data/spec/support/utils.rb +74 -1
  224. metadata +52 -10
  225. metadata.gz.sig +0 -0
  226. data/spec/support/crud/read.rb +0 -265
  227. data/spec/support/crud/write.rb +0 -284
@@ -2,6 +2,9 @@ runOn:
2
2
  -
3
3
  minServerVersion: "4.0"
4
4
  topology: ["replicaset"]
5
+ -
6
+ minServerVersion: "4.1.8"
7
+ topology: ["sharded"]
5
8
 
6
9
  database_name: &database_name "withTransaction-tests"
7
10
  collection_name: &collection_name "test"
@@ -12,6 +15,7 @@ tests:
12
15
  -
13
16
  # Session state will be ABORTED when callback returns to withTransaction
14
17
  description: withTransaction succeeds if callback aborts
18
+ useMultipleMongoses: true
15
19
  operations:
16
20
  -
17
21
  name: withTransaction
@@ -66,6 +70,7 @@ tests:
66
70
  -
67
71
  # Session state will be ABORTED when callback returns to withTransaction
68
72
  description: withTransaction succeeds if callback aborts with no ops
73
+ useMultipleMongoses: true
69
74
  operations:
70
75
  -
71
76
  name: withTransaction
@@ -83,6 +88,7 @@ tests:
83
88
  -
84
89
  # Session state will be NO_TXN when callback returns to withTransaction
85
90
  description: withTransaction still succeeds if callback aborts and runs extra op
91
+ useMultipleMongoses: true
86
92
  operations:
87
93
  -
88
94
  name: withTransaction
@@ -2,6 +2,9 @@ runOn:
2
2
  -
3
3
  minServerVersion: "4.0"
4
4
  topology: ["replicaset"]
5
+ -
6
+ minServerVersion: "4.1.8"
7
+ topology: ["sharded"]
5
8
 
6
9
  database_name: &database_name "withTransaction-tests"
7
10
  collection_name: &collection_name "test"
@@ -12,6 +15,7 @@ tests:
12
15
  -
13
16
  # Session state will be COMMITTED when callback returns to withTransaction
14
17
  description: withTransaction succeeds if callback commits
18
+ useMultipleMongoses: true
15
19
  operations:
16
20
  -
17
21
  name: withTransaction
@@ -92,6 +96,7 @@ tests:
92
96
  -
93
97
  # Session state will be NO_TXN when callback returns to withTransaction
94
98
  description: withTransaction still succeeds if callback commits and runs extra op
99
+ useMultipleMongoses: true
95
100
  operations:
96
101
  -
97
102
  name: withTransaction
@@ -2,6 +2,9 @@ runOn:
2
2
  -
3
3
  minServerVersion: "4.0"
4
4
  topology: ["replicaset"]
5
+ -
6
+ minServerVersion: "4.1.8"
7
+ topology: ["sharded"]
5
8
 
6
9
  database_name: &database_name "withTransaction-tests"
7
10
  collection_name: &collection_name "test"
@@ -132,6 +135,7 @@ tests:
132
135
  - { _id: 1 }
133
136
  -
134
137
  description: callback is not retried after non-transient error (DuplicateKeyError)
138
+ useMultipleMongoses: true
135
139
  operations:
136
140
  -
137
141
  name: withTransaction
@@ -154,10 +158,11 @@ tests:
154
158
  session: session0
155
159
  document: { _id: 1 }
156
160
  result:
157
- errorCodeName: DuplicateKey
158
161
  errorLabelsOmit: ["TransientTransactionError", "UnknownTransactionCommitResult"]
159
162
  result:
160
- errorCodeName: DuplicateKey
163
+ # Don't assert on errorCodeName because (after SERVER-38583) the
164
+ # DuplicateKey is reported in writeErrors, not as a top-level
165
+ # command error.
161
166
  errorLabelsOmit: ["TransientTransactionError", "UnknownTransactionCommitResult"]
162
167
  expectations:
163
168
  -
@@ -2,6 +2,9 @@ runOn:
2
2
  -
3
3
  minServerVersion: "4.0"
4
4
  topology: ["replicaset"]
5
+ -
6
+ minServerVersion: "4.1.8"
7
+ topology: ["sharded"]
5
8
 
6
9
  database_name: &database_name "withTransaction-tests"
7
10
  collection_name: &collection_name "test"
@@ -18,7 +21,7 @@ tests:
18
21
  failCommands: ["commitTransaction"]
19
22
  closeConnection: true
20
23
  operations:
21
- -
24
+ - &withTransaction
22
25
  name: withTransaction
23
26
  object: session0
24
27
  arguments:
@@ -191,20 +194,7 @@ tests:
191
194
  errorCode: 10107 # NotMaster
192
195
  closeConnection: false
193
196
  operations:
194
- -
195
- name: withTransaction
196
- object: session0
197
- arguments:
198
- callback:
199
- operations:
200
- -
201
- name: insertOne
202
- object: collection
203
- arguments:
204
- session: session0
205
- document: { _id: 1 }
206
- result:
207
- insertedId: 1
197
+ - *withTransaction
208
198
  expectations:
209
199
  -
210
200
  command_started_event:
@@ -267,3 +257,68 @@ tests:
267
257
  collection:
268
258
  data:
269
259
  - { _id: 1 }
260
+ -
261
+ description: commit is not retried after MaxTimeMSExpired error
262
+ failPoint:
263
+ configureFailPoint: failCommand
264
+ mode: { times: 1 }
265
+ data:
266
+ failCommands: ["commitTransaction"]
267
+ errorCode: 50 # MaxTimeMSExpired
268
+ operations:
269
+ - name: withTransaction
270
+ object: session0
271
+ arguments:
272
+ callback:
273
+ operations:
274
+ -
275
+ name: insertOne
276
+ object: collection
277
+ arguments:
278
+ session: session0
279
+ document: { _id: 1 }
280
+ result:
281
+ insertedId: 1
282
+ options:
283
+ maxCommitTimeMS: 60000
284
+ result:
285
+ errorCodeName: MaxTimeMSExpired
286
+ errorLabelsContain: ["UnknownTransactionCommitResult"]
287
+ errorLabelsOmit: ["TransientTransactionError"]
288
+ expectations:
289
+ -
290
+ command_started_event:
291
+ command:
292
+ insert: *collection_name
293
+ documents:
294
+ - { _id: 1 }
295
+ ordered: true
296
+ lsid: session0
297
+ txnNumber: { $numberLong: "1" }
298
+ startTransaction: true
299
+ autocommit: false
300
+ # omitted fields
301
+ readConcern: ~
302
+ writeConcern: ~
303
+ command_name: insert
304
+ database_name: *database_name
305
+ -
306
+ command_started_event:
307
+ command:
308
+ commitTransaction: 1
309
+ lsid: session0
310
+ txnNumber: { $numberLong: "1" }
311
+ autocommit: false
312
+ maxTimeMS: 60000
313
+ # omitted fields
314
+ readConcern: ~
315
+ startTransaction: ~
316
+ writeConcern: ~
317
+ command_name: commitTransaction
318
+ database_name: admin
319
+ outcome:
320
+ collection:
321
+ # In reality, the outcome of the commit is unknown but we fabricate
322
+ # the error with failCommand.errorCode which does not apply the commit
323
+ # operation.
324
+ data: []
@@ -2,6 +2,9 @@ runOn:
2
2
  -
3
3
  minServerVersion: "4.1.6"
4
4
  topology: ["replicaset"]
5
+ -
6
+ minServerVersion: "4.1.8"
7
+ topology: ["sharded"]
5
8
 
6
9
  database_name: &database_name "withTransaction-tests"
7
10
  collection_name: &collection_name "test"
@@ -2,6 +2,9 @@ runOn:
2
2
  -
3
3
  minServerVersion: "4.0"
4
4
  topology: ["replicaset"]
5
+ -
6
+ minServerVersion: "4.1.8"
7
+ topology: ["sharded"]
5
8
 
6
9
  database_name: &database_name "withTransaction-tests"
7
10
  collection_name: &collection_name "test"
@@ -2,6 +2,9 @@ runOn:
2
2
  -
3
3
  minServerVersion: "4.0"
4
4
  topology: ["replicaset"]
5
+ -
6
+ minServerVersion: "4.1.8"
7
+ topology: ["sharded"]
5
8
 
6
9
  database_name: &database_name "withTransaction-tests"
7
10
  collection_name: &collection_name "test"
@@ -10,10 +13,10 @@ data: []
10
13
 
11
14
  tests:
12
15
  -
13
- description: commitTransaction is not retried after WriteConcernFailed timeout error
16
+ description: commitTransaction is retried after WriteConcernFailed timeout error
14
17
  failPoint:
15
18
  configureFailPoint: failCommand
16
- mode: { times: 1 }
19
+ mode: { times: 2 }
17
20
  data:
18
21
  failCommands: ["commitTransaction"]
19
22
  # Do not specify closeConnection: false, since that would conflict
@@ -24,10 +27,10 @@ tests:
24
27
  errmsg: "waiting for replication timed out"
25
28
  errInfo: { wtimeout: true }
26
29
  operations:
27
- -
30
+ - &operation
28
31
  name: withTransaction
29
32
  object: session0
30
- arguments: &arguments
33
+ arguments:
31
34
  callback:
32
35
  operations:
33
36
  -
@@ -38,71 +41,7 @@ tests:
38
41
  document: { _id: 1 }
39
42
  result:
40
43
  insertedId: 1
41
- result:
42
- errorCodeName: WriteConcernFailed
43
- # Per transactions spec, drivers add UnknownTransactionCommitResult
44
- # label for WriteConcernFailed errors; however, neither the driver
45
- # nor withTransaction() will retry the commit in this case.
46
- errorLabelsContain: ["UnknownTransactionCommitResult"]
47
- errorLabelsOmit: ["TransientTransactionError"]
48
- expectations:
49
- -
50
- command_started_event:
51
- command:
52
- insert: *collection_name
53
- documents:
54
- - { _id: 1 }
55
- ordered: true
56
- lsid: session0
57
- txnNumber: { $numberLong: "1" }
58
- startTransaction: true
59
- autocommit: false
60
- # omitted fields
61
- readConcern: ~
62
- writeConcern: ~
63
- command_name: insert
64
- database_name: *database_name
65
- -
66
- command_started_event:
67
- command:
68
- commitTransaction: 1
69
- lsid: session0
70
- txnNumber: { $numberLong: "1" }
71
- autocommit: false
72
- # omitted fields
73
- readConcern: ~
74
- startTransaction: ~
75
- writeConcern: ~
76
- command_name: commitTransaction
77
- database_name: admin
78
- # The write operation is still applied despite the write concern error
79
- outcome: &outcome
80
- collection:
81
- data:
82
- - { _id: 1 }
83
- -
84
- # This test configures the fail point to return an error with the
85
- # WriteConcernFailed code but without errInfo that would identify it as a
86
- # wtimeout error. This tests that drivers do not assume that all
87
- # WriteConcernFailed errors are due to a replication timeout.
88
- description: commitTransaction is retried after WriteConcernFailed non-timeout error
89
- failPoint:
90
- configureFailPoint: failCommand
91
- mode: { times: 2 }
92
- data:
93
- failCommands: ["commitTransaction"]
94
- # Do not specify closeConnection: false, since that would conflict
95
- # with writeConcernError (see: SERVER-39292)
96
- writeConcernError:
97
- code: 64
98
- codeName: WriteConcernFailed
99
- errmsg: "multiple errors reported"
100
- operations:
101
- -
102
- name: withTransaction
103
- object: session0
104
- arguments: *arguments
105
- expectations:
44
+ expectations: &expectations_with_retries
106
45
  -
107
46
  command_started_event:
108
47
  command:
@@ -160,10 +99,32 @@ tests:
160
99
  startTransaction: ~
161
100
  command_name: commitTransaction
162
101
  database_name: admin
163
- outcome:
102
+ # The write operation is still applied despite the write concern error
103
+ outcome: &outcome
164
104
  collection:
165
105
  data:
166
106
  - { _id: 1 }
107
+ -
108
+ # This test configures the fail point to return an error with the
109
+ # WriteConcernFailed code but without errInfo that would identify it as a
110
+ # wtimeout error. This tests that drivers do not assume that all
111
+ # WriteConcernFailed errors are due to a replication timeout.
112
+ description: commitTransaction is retried after WriteConcernFailed non-timeout error
113
+ failPoint:
114
+ configureFailPoint: failCommand
115
+ mode: { times: 2 }
116
+ data:
117
+ failCommands: ["commitTransaction"]
118
+ # Do not specify closeConnection: false, since that would conflict
119
+ # with writeConcernError (see: SERVER-39292)
120
+ writeConcernError:
121
+ code: 64
122
+ codeName: WriteConcernFailed
123
+ errmsg: "multiple errors reported"
124
+ operations:
125
+ - *operation
126
+ expectations: *expectations_with_retries
127
+ outcome: *outcome
167
128
  -
168
129
  description: commitTransaction is not retried after UnknownReplWriteConcern error
169
130
  failPoint:
@@ -176,14 +137,11 @@ tests:
176
137
  codeName: UnknownReplWriteConcern
177
138
  errmsg: "No write concern mode named 'foo' found in replica set configuration"
178
139
  operations:
179
- -
180
- name: withTransaction
181
- object: session0
182
- arguments: *arguments
140
+ - <<: *operation
183
141
  result:
184
142
  errorCodeName: UnknownReplWriteConcern
185
143
  errorLabelsOmit: ["TransientTransactionError", "UnknownTransactionCommitResult"]
186
- expectations:
144
+ expectations: &expectations_without_retries
187
145
  -
188
146
  command_started_event:
189
147
  command:
@@ -213,7 +171,9 @@ tests:
213
171
  writeConcern: ~
214
172
  command_name: commitTransaction
215
173
  database_name: admin
174
+ # failCommand with writeConcernError still applies the write operation(s)
216
175
  outcome: *outcome
176
+
217
177
  -
218
178
  description: commitTransaction is not retried after UnsatisfiableWriteConcern error
219
179
  failPoint:
@@ -226,41 +186,31 @@ tests:
226
186
  codeName: UnsatisfiableWriteConcern
227
187
  errmsg: "Not enough data-bearing nodes"
228
188
  operations:
229
- -
230
- name: withTransaction
231
- object: session0
232
- arguments: *arguments
189
+ - <<: *operation
233
190
  result:
234
191
  errorCodeName: UnsatisfiableWriteConcern
235
192
  errorLabelsOmit: ["TransientTransactionError", "UnknownTransactionCommitResult"]
236
- expectations:
237
- -
238
- command_started_event:
239
- command:
240
- insert: *collection_name
241
- documents:
242
- - { _id: 1 }
243
- ordered: true
244
- lsid: session0
245
- txnNumber: { $numberLong: "1" }
246
- startTransaction: true
247
- autocommit: false
248
- # omitted fields
249
- readConcern: ~
250
- writeConcern: ~
251
- command_name: insert
252
- database_name: *database_name
253
- -
254
- command_started_event:
255
- command:
256
- commitTransaction: 1
257
- lsid: session0
258
- txnNumber: { $numberLong: "1" }
259
- autocommit: false
260
- # omitted fields
261
- readConcern: ~
262
- startTransaction: ~
263
- writeConcern: ~
264
- command_name: commitTransaction
265
- database_name: admin
193
+ expectations: *expectations_without_retries
194
+ # failCommand with writeConcernError still applies the write operation(s)
195
+ outcome: *outcome
196
+
197
+ -
198
+ description: commitTransaction is not retried after MaxTimeMSExpired error
199
+ failPoint:
200
+ configureFailPoint: failCommand
201
+ mode: { times: 1 }
202
+ data:
203
+ failCommands: ["commitTransaction"]
204
+ writeConcernError:
205
+ code: 50
206
+ codeName: MaxTimeMSExpired
207
+ errmsg: "operation exceeded time limit"
208
+ operations:
209
+ - <<: *operation
210
+ result:
211
+ errorCodeName: MaxTimeMSExpired
212
+ errorLabelsContain: ["UnknownTransactionCommitResult"]
213
+ errorLabelsOmit: ["TransientTransactionError"]
214
+ expectations: *expectations_without_retries
215
+ # failCommand with writeConcernError still applies the write operation(s)
266
216
  outcome: *outcome