Skip to content

Commit c29c214

Browse files
committed
PYTHON-1828 Send recoveryToken on abortTransaction
1 parent 87793a9 commit c29c214

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

pymongo/client_session.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -635,14 +635,13 @@ def _finish_transaction(self, command_name, retrying):
635635
# subsequent commitTransaction commands should be upgraded to use
636636
# w:"majority" and set a default value of 10 seconds for wtimeout.
637637
wc = self._transaction.opts.write_concern
638-
is_commit = command_name == "commitTransaction"
639-
if retrying and is_commit:
638+
if retrying and command_name == "commitTransaction":
640639
wc_doc = wc.document
641640
wc_doc["w"] = "majority"
642641
wc_doc.setdefault("wtimeout", 10000)
643642
wc = WriteConcern(**wc_doc)
644643
cmd = SON([(command_name, 1)])
645-
if self._transaction.recovery_token and is_commit:
644+
if self._transaction.recovery_token:
646645
cmd['recoveryToken'] = self._transaction.recovery_token
647646
with self._client._socket_for_writes(self) as sock_info:
648647
return self._client.admin._command(

test/transactions/mongos-pin-auto.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@
296296
"startTransaction": null,
297297
"autocommit": false,
298298
"writeConcern": null,
299-
"recoveryToken": null
299+
"recoveryToken": 42
300300
},
301301
"command_name": "abortTransaction",
302302
"database_name": "admin"

test/transactions/mongos-recovery-token.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@
393393
}
394394
},
395395
{
396-
"description": "abortTransaction does not send recoveryToken",
396+
"description": "abortTransaction sends recoveryToken",
397397
"useMultipleMongoses": true,
398398
"operations": [
399399
{
@@ -472,7 +472,7 @@
472472
"startTransaction": null,
473473
"autocommit": false,
474474
"writeConcern": null,
475-
"recoveryToken": null
475+
"recoveryToken": 42
476476
},
477477
"command_name": "abortTransaction",
478478
"database_name": "admin"
@@ -489,7 +489,7 @@
489489
"startTransaction": null,
490490
"autocommit": false,
491491
"writeConcern": null,
492-
"recoveryToken": null
492+
"recoveryToken": 42
493493
},
494494
"command_name": "abortTransaction",
495495
"database_name": "admin"

test/transactions/pin-mongos.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@
10491049
"startTransaction": null,
10501050
"autocommit": false,
10511051
"writeConcern": null,
1052-
"recoveryToken": null
1052+
"recoveryToken": 42
10531053
},
10541054
"command_name": "abortTransaction",
10551055
"database_name": "admin"

0 commit comments

Comments
 (0)