File tree Expand file tree Collapse file tree 4 files changed +9
-10
lines changed
test/integration/retryable-writes Expand file tree Collapse file tree 4 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,6 @@ import {
31
31
MIN_SUPPORTED_SERVER_VERSION ,
32
32
MIN_SUPPORTED_WIRE_VERSION
33
33
} from './wire_protocol/constants' ;
34
- import { isSharded } from './wire_protocol/shared' ;
35
34
36
35
/** @public */
37
36
export type Stream = Socket | TLSSocket ;
@@ -165,7 +164,7 @@ export async function performInitialHandshake(
165
164
} catch ( error ) {
166
165
if ( error instanceof MongoError ) {
167
166
error . addErrorLabel ( MongoErrorLabel . HandshakeError ) ;
168
- if ( needsRetryableWriteLabel ( error , response . maxWireVersion , isSharded ( conn ) ) ) {
167
+ if ( needsRetryableWriteLabel ( error , response . maxWireVersion , conn . description . type ) ) {
169
168
error . addErrorLabel ( MongoErrorLabel . RetryableWriteError ) ;
170
169
}
171
170
}
Original file line number Diff line number Diff line change 1
1
import type { Document } from './bson' ;
2
+ import type { ServerType } from './sdam/common' ;
2
3
import type { TopologyVersion } from './sdam/server_description' ;
3
4
import type { TopologyDescription } from './sdam/topology_description' ;
4
5
@@ -1220,7 +1221,7 @@ const RETRYABLE_WRITE_ERROR_CODES = RETRYABLE_READ_ERROR_CODES;
1220
1221
export function needsRetryableWriteLabel (
1221
1222
error : Error ,
1222
1223
maxWireVersion : number ,
1223
- isSharded : boolean
1224
+ serverType : ServerType
1224
1225
) : boolean {
1225
1226
// pre-4.4 server, then the driver adds an error label for every valid case
1226
1227
// execute operation will only inspect the label, code/message logic is handled here
@@ -1241,13 +1242,13 @@ export function needsRetryableWriteLabel(
1241
1242
}
1242
1243
1243
1244
if ( error instanceof MongoWriteConcernError ) {
1244
- return isSharded && maxWireVersion < 9
1245
+ return serverType === 'Mongos' && maxWireVersion < 9
1245
1246
? false
1246
- : RETRYABLE_WRITE_ERROR_CODES . has ( error . result ?. code ?? error . code ?? 0 ) ;
1247
+ : RETRYABLE_WRITE_ERROR_CODES . has ( error . result ?. code ?? Number ( error . code ) ?? 0 ) ;
1247
1248
}
1248
1249
1249
1250
if ( error instanceof MongoError && typeof error . code === 'number' ) {
1250
- return RETRYABLE_WRITE_ERROR_CODES . has ( error . code ) ;
1251
+ return RETRYABLE_WRITE_ERROR_CODES . has ( Number ( error . code ) ) ;
1251
1252
}
1252
1253
1253
1254
const isNotWritablePrimaryError = LEGACY_NOT_WRITABLE_PRIMARY_ERROR_MESSAGE . test ( error . message ) ;
Original file line number Diff line number Diff line change 8
8
} from '../cmap/connection_pool' ;
9
9
import { PoolClearedError } from '../cmap/errors' ;
10
10
import { type MongoDBResponseConstructor } from '../cmap/wire_protocol/responses' ;
11
- import { isSharded } from '../cmap/wire_protocol/shared' ;
12
11
import {
13
12
APM_EVENTS ,
14
13
CLOSED ,
@@ -454,7 +453,7 @@ export class Server extends TypedEventEmitter<ServerEvents> {
454
453
} else {
455
454
if (
456
455
( isRetryableWritesEnabled ( this . topology ) || isTransactionCommand ( cmd ) ) &&
457
- needsRetryableWriteLabel ( error , maxWireVersion ( this ) , isSharded ( this ) ) &&
456
+ needsRetryableWriteLabel ( error , maxWireVersion ( this ) , this . description . type ) &&
458
457
! inActiveTransaction ( session , cmd )
459
458
) {
460
459
error . addErrorLabel ( MongoErrorLabel . RetryableWriteError ) ;
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ interface RetryableWriteTestContext {
15
15
failPointName ?: any ;
16
16
}
17
17
18
- describe . only ( 'Legacy Retryable Writes Specs' , function ( ) {
18
+ describe ( 'Legacy Retryable Writes Specs' , function ( ) {
19
19
let ctx : RetryableWriteTestContext = { } ;
20
20
21
21
const retryableWrites = loadSpecTests ( 'retryable-writes' , 'legacy' ) ;
@@ -229,6 +229,6 @@ async function turnOffFailPoint(client, name) {
229
229
} ) ;
230
230
}
231
231
232
- describe . only ( 'Retryable Writes (unified)' , function ( ) {
232
+ describe ( 'Retryable Writes (unified)' , function ( ) {
233
233
runUnifiedSuite ( loadSpecTests ( path . join ( 'retryable-writes' , 'unified' ) ) ) ;
234
234
} ) ;
You can’t perform that action at this time.
0 commit comments