mongodb-core
Advanced tools
Comparing version 3.1.0-beta3 to 3.1.0-beta4
@@ -898,2 +898,3 @@ 'use strict'; | ||
// increment and assign txnNumber | ||
options.willRetryWrite = true; | ||
options.session.incrementTransactionNumber(); | ||
@@ -900,0 +901,0 @@ |
@@ -1234,2 +1234,3 @@ 'use strict'; | ||
options.session.incrementTransactionNumber(); | ||
options.willRetryWrite = willRetryWrite; | ||
} | ||
@@ -1236,0 +1237,0 @@ |
@@ -21,4 +21,5 @@ 'use strict'; | ||
* @param {ClientSession} session the session tracking transaction state | ||
* @param {boolean} [isRetryableWrite=false] if true, will be decorated for retryable writes | ||
*/ | ||
function decorateWithTransactionsData(command, session) { | ||
function decorateWithTransactionsData(command, session, isRetryableWrite) { | ||
if (!session) { | ||
@@ -30,3 +31,5 @@ return; | ||
const serverSession = session.serverSession; | ||
if (serverSession.txnNumber) { | ||
const inTransaction = session.inTransaction(); | ||
if (serverSession.txnNumber && (isRetryableWrite || inTransaction)) { | ||
command.txnNumber = BSON.Long.fromNumber(serverSession.txnNumber); | ||
@@ -36,3 +39,3 @@ } | ||
// now try to apply tansaction-specific data | ||
if (!session.inTransaction()) { | ||
if (!inTransaction) { | ||
return; | ||
@@ -109,3 +112,3 @@ } | ||
// optionally decorate command with transactions data | ||
decorateWithTransactionsData(writeCommand, options.session); | ||
decorateWithTransactionsData(writeCommand, options.session, options.willRetryWrite); | ||
@@ -112,0 +115,0 @@ // Options object |
{ | ||
"name": "mongodb-core", | ||
"version": "3.1.0-beta3", | ||
"version": "3.1.0-beta4", | ||
"description": "Core MongoDB driver functionality, no bells and whistles and meant for integration not end applications", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
524818
12512