File tree Expand file tree Collapse file tree
test/integration/client-backpressure Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -389,12 +389,27 @@ async function executeOperationWithRetries<
389389 ) ;
390390
391391 function canRetry ( operation : AbstractOperation , error : MongoError ) {
392- // always retryable
392+ // SystemOverloadedError is retryable, but must respect retryReads/retryWrites settings
393+ // Check topology options directly (not operation.canRetryRead/Write) because backpressure
394+ // expands retry support beyond traditional retryable reads/writes
393395 if (
394396 error . hasErrorLabel ( MongoErrorLabel . SystemOverloadedError ) &&
395397 error . hasErrorLabel ( MongoErrorLabel . RetryableError )
396398 ) {
397- return true ;
399+ // runCommand requires BOTH retryReads and retryWrites to be enabled (per spec step 2.4)
400+ if ( operation instanceof RunCommandOperation ) {
401+ return topology . s . options . retryReads && topology . s . options . retryWrites && ! inTransaction ;
402+ }
403+
404+ // Write-stage aggregates ($out/$merge) require retryWrites
405+ if ( operation instanceof AggregateOperation && operation . hasWriteStage ) {
406+ return topology . s . options . retryWrites && ! inTransaction ;
407+ }
408+
409+ // 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 ;
412+ return canRetryAsRead || canRetryAsWrite ;
398413 }
399414
400415 // run command is only retryable if we get retryable overload errors
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ import { type Test } from '../../tools/unified-spec-runner/schema';
44
55const skippedTests = {
66 'collection.dropIndexes retries at most maxAttempts=5 times' :
7+ 'TODO(NODE-6517): dropIndexes squashes all errors other than ns not found' ,
8+ 'collection.dropIndexes (write) does not retry if retryWrites=false' :
79 'TODO(NODE-6517): dropIndexes squashes all errors other than ns not found'
810} ;
911
You can’t perform that action at this time.
0 commit comments