Comparing version 6.9.0-dev.20241016.sha.3d5bd513 to 6.9.0-dev.20241018.sha.a7d1d43e
@@ -266,2 +266,3 @@ "use strict"; | ||
} | ||
this.commitAttempted = false; | ||
// increment txnNumber | ||
@@ -305,3 +306,3 @@ this.incrementTransactionNumber(); | ||
} | ||
if (this.transaction.state === transactions_1.TxnState.TRANSACTION_COMMITTED) { | ||
if (this.transaction.state === transactions_1.TxnState.TRANSACTION_COMMITTED || this.commitAttempted) { | ||
write_concern_1.WriteConcern.apply(command, { wtimeoutMS: 10000, ...wc, w: 'majority' }); | ||
@@ -322,5 +323,7 @@ } | ||
await (0, execute_operation_1.executeOperation)(this.client, operation); | ||
this.commitAttempted = undefined; | ||
return; | ||
} | ||
catch (firstCommitError) { | ||
this.commitAttempted = true; | ||
if (firstCommitError instanceof error_1.MongoError && (0, error_1.isRetryableWriteError)(firstCommitError)) { | ||
@@ -332,3 +335,7 @@ // SPEC-1185: apply majority write concern when retrying commitTransaction | ||
try { | ||
await (0, execute_operation_1.executeOperation)(this.client, operation); | ||
await (0, execute_operation_1.executeOperation)(this.client, new run_command_1.RunAdminCommandOperation(command, { | ||
session: this, | ||
readPreference: read_preference_1.ReadPreference.primary, | ||
bypassPinningCheck: true | ||
})); | ||
return; | ||
@@ -335,0 +342,0 @@ } |
{ | ||
"name": "mongodb", | ||
"version": "6.9.0-dev.20241016.sha.3d5bd513", | ||
"version": "6.9.0-dev.20241018.sha.a7d1d43e", | ||
"description": "The official MongoDB driver for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -127,2 +127,6 @@ import { Binary, type Document, Long, type Timestamp } from './bson'; | ||
transaction: Transaction; | ||
/** @internal | ||
* Keeps track of whether or not the current transaction has attempted to be committed. Is | ||
* initially undefined. Gets set to false when startTransaction is called. When commitTransaction is sent to server, if the commitTransaction succeeds, it is then set to undefined, otherwise, set to true */ | ||
commitAttempted?: boolean; | ||
/** @internal */ | ||
@@ -421,2 +425,3 @@ [kServerSession]: ServerSession | null; | ||
this.commitAttempted = false; | ||
// increment txnNumber | ||
@@ -479,3 +484,3 @@ this.incrementTransactionNumber(); | ||
if (this.transaction.state === TxnState.TRANSACTION_COMMITTED) { | ||
if (this.transaction.state === TxnState.TRANSACTION_COMMITTED || this.commitAttempted) { | ||
WriteConcern.apply(command, { wtimeoutMS: 10000, ...wc, w: 'majority' }); | ||
@@ -500,4 +505,6 @@ } | ||
await executeOperation(this.client, operation); | ||
this.commitAttempted = undefined; | ||
return; | ||
} catch (firstCommitError) { | ||
this.commitAttempted = true; | ||
if (firstCommitError instanceof MongoError && isRetryableWriteError(firstCommitError)) { | ||
@@ -510,3 +517,10 @@ // SPEC-1185: apply majority write concern when retrying commitTransaction | ||
try { | ||
await executeOperation(this.client, operation); | ||
await executeOperation( | ||
this.client, | ||
new RunAdminCommandOperation(command, { | ||
session: this, | ||
readPreference: ReadPreference.primary, | ||
bypassPinningCheck: true | ||
}) | ||
); | ||
return; | ||
@@ -513,0 +527,0 @@ } catch (retryCommitError) { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
3517907
73512
21
27
5
167