Skip to content

Commit 3ffa08f

Browse files
committed
fix transaction tests
1 parent 2f745fd commit 3ffa08f

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/operations/execute_operation.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,23 +392,24 @@ async function executeOperationWithRetries<
392392
// SystemOverloadedError is retryable, but must respect retryReads/retryWrites settings
393393
// Check topology options directly (not operation.canRetryRead/Write) because backpressure
394394
// expands retry support beyond traditional retryable reads/writes
395+
// NOTE: Unlike traditional retries, backpressure retries ARE allowed inside transactions
395396
if (
396397
error.hasErrorLabel(MongoErrorLabel.SystemOverloadedError) &&
397398
error.hasErrorLabel(MongoErrorLabel.RetryableError)
398399
) {
399400
// runCommand requires BOTH retryReads and retryWrites to be enabled (per spec step 2.4)
400401
if (operation instanceof RunCommandOperation) {
401-
return topology.s.options.retryReads && topology.s.options.retryWrites && !inTransaction;
402+
return topology.s.options.retryReads && topology.s.options.retryWrites;
402403
}
403404

404405
// Write-stage aggregates ($out/$merge) require retryWrites
405406
if (operation instanceof AggregateOperation && operation.hasWriteStage) {
406-
return topology.s.options.retryWrites && !inTransaction;
407+
return topology.s.options.retryWrites;
407408
}
408409

409410
// For other operations, check if retries are enabled based on operation type
410-
const canRetryAsRead = hasReadAspect && topology.s.options.retryReads && !inTransaction;
411-
const canRetryAsWrite = hasWriteAspect && topology.s.options.retryWrites && !inTransaction;
411+
const canRetryAsRead = hasReadAspect && topology.s.options.retryReads;
412+
const canRetryAsWrite = hasWriteAspect && topology.s.options.retryWrites;
412413
return canRetryAsRead || canRetryAsWrite;
413414
}
414415

0 commit comments

Comments
 (0)