Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/operations/execute_operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,28 @@ async function executeOperationWithRetries<
);

function canRetry(operation: AbstractOperation, error: MongoError) {
// always retryable
// SystemOverloadedError is retryable, but must respect retryReads/retryWrites settings
// Check topology options directly (not operation.canRetryRead/Write) because backpressure
// expands retry support beyond traditional retryable reads/writes
// NOTE: Unlike traditional retries, backpressure retries ARE allowed inside transactions
if (
error.hasErrorLabel(MongoErrorLabel.SystemOverloadedError) &&
error.hasErrorLabel(MongoErrorLabel.RetryableError)
) {
return true;
// runCommand requires BOTH retryReads and retryWrites to be enabled (per spec step 2.4)
if (operation instanceof RunCommandOperation) {
return topology.s.options.retryReads && topology.s.options.retryWrites;
}

// Write-stage aggregates ($out/$merge) require retryWrites
if (operation instanceof AggregateOperation && operation.hasWriteStage) {
return topology.s.options.retryWrites;
}

// For other operations, check if retries are enabled based on operation type
const canRetryAsRead = hasReadAspect && topology.s.options.retryReads;
const canRetryAsWrite = hasWriteAspect && topology.s.options.retryWrites;
return canRetryAsRead || canRetryAsWrite;
}

// run command is only retryable if we get retryable overload errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { type Test } from '../../tools/unified-spec-runner/schema';

const skippedTests = {
'collection.dropIndexes retries at most maxAttempts=5 times':
'TODO(NODE-6517): dropIndexes squashes all errors other than ns not found',
'collection.dropIndexes (write) does not retry if retryWrites=false':
'TODO(NODE-6517): dropIndexes squashes all errors other than ns not found'
};

Expand Down
Loading
Loading