Skip to content

Commit 5d7e5a2

Browse files
committed
Allow applications to set maxTimeMS for commitTransaction
GODRIVER-1081 Change-Id: I88b152181e1af7e8fa287fe57f19278826062dd8
1 parent 60e65d0 commit 5d7e5a2

22 files changed

+2837
-871
lines changed

data/convenient-transactions/README.rst

Lines changed: 448 additions & 165 deletions
Large diffs are not rendered by default.

data/convenient-transactions/commit-retry.json

Lines changed: 69 additions & 183 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
"data": [],
1919
"tests": [
2020
{
21-
"description": "commitTransaction succeeds after multiple connection errors",
21+
"description": "callback succeeds after multiple connection errors",
2222
"failPoint": {
2323
"configureFailPoint": "failCommand",
2424
"mode": {
2525
"times": 2
2626
},
2727
"data": {
2828
"failCommands": [
29-
"commitTransaction"
29+
"insert"
3030
],
3131
"closeConnection": true
3232
}
@@ -46,9 +46,6 @@
4646
"document": {
4747
"_id": 1
4848
}
49-
},
50-
"result": {
51-
"insertedId": 1
5249
}
5350
}
5451
]
@@ -83,7 +80,7 @@
8380
{
8481
"command_started_event": {
8582
"command": {
86-
"commitTransaction": 1,
83+
"abortTransaction": 1,
8784
"lsid": "session0",
8885
"txnNumber": {
8986
"$numberLong": "1"
@@ -93,108 +90,10 @@
9390
"startTransaction": null,
9491
"writeConcern": null
9592
},
96-
"command_name": "commitTransaction",
93+
"command_name": "abortTransaction",
9794
"database_name": "admin"
9895
}
9996
},
100-
{
101-
"command_started_event": {
102-
"command": {
103-
"commitTransaction": 1,
104-
"lsid": "session0",
105-
"txnNumber": {
106-
"$numberLong": "1"
107-
},
108-
"autocommit": false,
109-
"writeConcern": {
110-
"w": "majority",
111-
"wtimeout": 10000
112-
},
113-
"readConcern": null,
114-
"startTransaction": null
115-
},
116-
"command_name": "commitTransaction",
117-
"database_name": "admin"
118-
}
119-
},
120-
{
121-
"command_started_event": {
122-
"command": {
123-
"commitTransaction": 1,
124-
"lsid": "session0",
125-
"txnNumber": {
126-
"$numberLong": "1"
127-
},
128-
"autocommit": false,
129-
"writeConcern": {
130-
"w": "majority",
131-
"wtimeout": 10000
132-
},
133-
"readConcern": null,
134-
"startTransaction": null
135-
},
136-
"command_name": "commitTransaction",
137-
"database_name": "admin"
138-
}
139-
}
140-
],
141-
"outcome": {
142-
"collection": {
143-
"data": [
144-
{
145-
"_id": 1
146-
}
147-
]
148-
}
149-
}
150-
},
151-
{
152-
"description": "commitTransaction retry only overwrites write concern w option",
153-
"failPoint": {
154-
"configureFailPoint": "failCommand",
155-
"mode": {
156-
"times": 2
157-
},
158-
"data": {
159-
"failCommands": [
160-
"commitTransaction"
161-
],
162-
"closeConnection": true
163-
}
164-
},
165-
"operations": [
166-
{
167-
"name": "withTransaction",
168-
"object": "session0",
169-
"arguments": {
170-
"callback": {
171-
"operations": [
172-
{
173-
"name": "insertOne",
174-
"object": "collection",
175-
"arguments": {
176-
"session": "session0",
177-
"document": {
178-
"_id": 1
179-
}
180-
},
181-
"result": {
182-
"insertedId": 1
183-
}
184-
}
185-
]
186-
},
187-
"options": {
188-
"writeConcern": {
189-
"w": 2,
190-
"j": true,
191-
"wtimeout": 5000
192-
}
193-
}
194-
}
195-
}
196-
],
197-
"expectations": [
19897
{
19998
"command_started_event": {
20099
"command": {
@@ -206,12 +105,14 @@
206105
],
207106
"ordered": true,
208107
"lsid": "session0",
108+
"readConcern": {
109+
"afterClusterTime": 42
110+
},
209111
"txnNumber": {
210-
"$numberLong": "1"
112+
"$numberLong": "2"
211113
},
212114
"startTransaction": true,
213115
"autocommit": false,
214-
"readConcern": null,
215116
"writeConcern": null
216117
},
217118
"command_name": "insert",
@@ -221,43 +122,43 @@
221122
{
222123
"command_started_event": {
223124
"command": {
224-
"commitTransaction": 1,
125+
"abortTransaction": 1,
225126
"lsid": "session0",
226127
"txnNumber": {
227-
"$numberLong": "1"
128+
"$numberLong": "2"
228129
},
229130
"autocommit": false,
230-
"writeConcern": {
231-
"w": 2,
232-
"j": true,
233-
"wtimeout": 5000
234-
},
235131
"readConcern": null,
236-
"startTransaction": null
132+
"startTransaction": null,
133+
"writeConcern": null
237134
},
238-
"command_name": "commitTransaction",
135+
"command_name": "abortTransaction",
239136
"database_name": "admin"
240137
}
241138
},
242139
{
243140
"command_started_event": {
244141
"command": {
245-
"commitTransaction": 1,
142+
"insert": "test",
143+
"documents": [
144+
{
145+
"_id": 1
146+
}
147+
],
148+
"ordered": true,
246149
"lsid": "session0",
150+
"readConcern": {
151+
"afterClusterTime": 42
152+
},
247153
"txnNumber": {
248-
"$numberLong": "1"
154+
"$numberLong": "3"
249155
},
156+
"startTransaction": true,
250157
"autocommit": false,
251-
"writeConcern": {
252-
"w": "majority",
253-
"j": true,
254-
"wtimeout": 5000
255-
},
256-
"readConcern": null,
257-
"startTransaction": null
158+
"writeConcern": null
258159
},
259-
"command_name": "commitTransaction",
260-
"database_name": "admin"
160+
"command_name": "insert",
161+
"database_name": "withTransaction-tests"
261162
}
262163
},
263164
{
@@ -266,16 +167,12 @@
266167
"commitTransaction": 1,
267168
"lsid": "session0",
268169
"txnNumber": {
269-
"$numberLong": "1"
170+
"$numberLong": "3"
270171
},
271172
"autocommit": false,
272-
"writeConcern": {
273-
"w": "majority",
274-
"j": true,
275-
"wtimeout": 5000
276-
},
277173
"readConcern": null,
278-
"startTransaction": null
174+
"startTransaction": null,
175+
"writeConcern": null
279176
},
280177
"command_name": "commitTransaction",
281178
"database_name": "admin"
@@ -293,20 +190,8 @@
293190
}
294191
},
295192
{
296-
"description": "commit is retried after commitTransaction UnknownTransactionCommitResult (NotMaster)",
297-
"failPoint": {
298-
"configureFailPoint": "failCommand",
299-
"mode": {
300-
"times": 2
301-
},
302-
"data": {
303-
"failCommands": [
304-
"commitTransaction"
305-
],
306-
"errorCode": 10107,
307-
"closeConnection": false
308-
}
309-
},
193+
"description": "callback is not retried after non-transient error (DuplicateKeyError)",
194+
"useMultipleMongoses": true,
310195
"operations": [
311196
{
312197
"name": "withTransaction",
@@ -326,9 +211,31 @@
326211
"result": {
327212
"insertedId": 1
328213
}
214+
},
215+
{
216+
"name": "insertOne",
217+
"object": "collection",
218+
"arguments": {
219+
"session": "session0",
220+
"document": {
221+
"_id": 1
222+
}
223+
},
224+
"result": {
225+
"errorLabelsOmit": [
226+
"TransientTransactionError",
227+
"UnknownTransactionCommitResult"
228+
]
229+
}
329230
}
330231
]
331232
}
233+
},
234+
"result": {
235+
"errorLabelsOmit": [
236+
"TransientTransactionError",
237+
"UnknownTransactionCommitResult"
238+
]
332239
}
333240
}
334241
],
@@ -359,7 +266,13 @@
359266
{
360267
"command_started_event": {
361268
"command": {
362-
"commitTransaction": 1,
269+
"insert": "test",
270+
"documents": [
271+
{
272+
"_id": 1
273+
}
274+
],
275+
"ordered": true,
363276
"lsid": "session0",
364277
"txnNumber": {
365278
"$numberLong": "1"
@@ -369,58 +282,31 @@
369282
"startTransaction": null,
370283
"writeConcern": null
371284
},
372-
"command_name": "commitTransaction",
373-
"database_name": "admin"
374-
}
375-
},
376-
{
377-
"command_started_event": {
378-
"command": {
379-
"commitTransaction": 1,
380-
"lsid": "session0",
381-
"txnNumber": {
382-
"$numberLong": "1"
383-
},
384-
"autocommit": false,
385-
"writeConcern": {
386-
"w": "majority",
387-
"wtimeout": 10000
388-
},
389-
"readConcern": null,
390-
"startTransaction": null
391-
},
392-
"command_name": "commitTransaction",
393-
"database_name": "admin"
285+
"command_name": "insert",
286+
"database_name": "withTransaction-tests"
394287
}
395288
},
396289
{
397290
"command_started_event": {
398291
"command": {
399-
"commitTransaction": 1,
292+
"abortTransaction": 1,
400293
"lsid": "session0",
401294
"txnNumber": {
402295
"$numberLong": "1"
403296
},
404297
"autocommit": false,
405-
"writeConcern": {
406-
"w": "majority",
407-
"wtimeout": 10000
408-
},
409298
"readConcern": null,
410-
"startTransaction": null
299+
"startTransaction": null,
300+
"writeConcern": null
411301
},
412-
"command_name": "commitTransaction",
302+
"command_name": "abortTransaction",
413303
"database_name": "admin"
414304
}
415305
}
416306
],
417307
"outcome": {
418308
"collection": {
419-
"data": [
420-
{
421-
"_id": 1
422-
}
423-
]
309+
"data": []
424310
}
425311
}
426312
}

0 commit comments

Comments
 (0)