diff --git a/.evergreen/config.yml b/.evergreen/config.yml index e4eeb561cc..fc56a7dfb0 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -1338,54 +1338,6 @@ tasks: - func: install dependencies - func: bootstrap mongo-orchestration - func: run tests - - name: test-4.2-server - tags: - - '4.2' - - server - commands: - - command: expansions.update - type: setup - params: - updates: - - {key: VERSION, value: '4.2'} - - {key: TOPOLOGY, value: server} - - {key: SSL, value: nossl} - - {key: AUTH, value: auth} - - func: install dependencies - - func: bootstrap mongo-orchestration - - func: run tests - - name: test-4.2-replica_set - tags: - - '4.2' - - replica_set - commands: - - command: expansions.update - type: setup - params: - updates: - - {key: VERSION, value: '4.2'} - - {key: TOPOLOGY, value: replica_set} - - {key: SSL, value: nossl} - - {key: AUTH, value: auth} - - func: install dependencies - - func: bootstrap mongo-orchestration - - func: run tests - - name: test-4.2-sharded_cluster - tags: - - '4.2' - - sharded_cluster - commands: - - command: expansions.update - type: setup - params: - updates: - - {key: VERSION, value: '4.2'} - - {key: TOPOLOGY, value: sharded_cluster} - - {key: SSL, value: nossl} - - {key: AUTH, value: auth} - - func: install dependencies - - func: bootstrap mongo-orchestration - - func: run tests - name: test-latest-server-v1-api tags: - latest @@ -1741,22 +1693,6 @@ tasks: - func: install dependencies - func: bootstrap mongo-orchestration - func: run tls tests - - name: test-tls-support-4.2 - tags: - - tls-support - - tls-support-4.2 - commands: - - command: expansions.update - type: setup - params: - updates: - - {key: VERSION, value: '4.2'} - - {key: SSL, value: ssl} - - {key: TOPOLOGY, value: server} - - {key: AUTH, value: auth} - - func: install dependencies - - func: bootstrap mongo-orchestration - - func: run tls tests - name: aws-latest-auth-test-run-aws-auth-test-with-regular-aws-credentials commands: - command: expansions.update @@ -2545,60 +2481,6 @@ tasks: - func: install dependencies - func: bootstrap mongo-orchestration - func: run tests - - name: test-4.2-server-noauth - tags: - - '4.2' - - server - - noauth - commands: - - command: expansions.update - type: setup - params: - updates: - - {key: VERSION, value: '4.2'} - - {key: TOPOLOGY, value: server} - - {key: AUTH, value: noauth} - - {key: SSL, value: nossl} - - {key: NODE_LTS_VERSION, value: 20.19.0} - - func: install dependencies - - func: bootstrap mongo-orchestration - - func: run tests - - name: test-4.2-replica_set-noauth - tags: - - '4.2' - - replica_set - - noauth - commands: - - command: expansions.update - type: setup - params: - updates: - - {key: VERSION, value: '4.2'} - - {key: TOPOLOGY, value: replica_set} - - {key: AUTH, value: noauth} - - {key: SSL, value: nossl} - - {key: NODE_LTS_VERSION, value: 20.19.0} - - func: install dependencies - - func: bootstrap mongo-orchestration - - func: run tests - - name: test-4.2-sharded_cluster-noauth - tags: - - '4.2' - - sharded_cluster - - noauth - commands: - - command: expansions.update - type: setup - params: - updates: - - {key: VERSION, value: '4.2'} - - {key: TOPOLOGY, value: sharded_cluster} - - {key: AUTH, value: noauth} - - {key: SSL, value: nossl} - - {key: NODE_LTS_VERSION, value: 20.19.0} - - func: install dependencies - - func: bootstrap mongo-orchestration - - func: run tests - name: test-lambda-example tags: - latest @@ -2744,22 +2626,6 @@ tasks: - func: install dependencies - func: bootstrap mongo-orchestration - func: run tests - - name: test-4.2-csfle-mongocryptd - tags: - - '4.2' - - sharded_cluster - commands: - - command: expansions.update - type: setup - params: - updates: - - {key: VERSION, value: '4.2'} - - {key: TOPOLOGY, value: sharded_cluster} - - {key: AUTH, value: auth} - - {key: NODE_LTS_VERSION, value: '24'} - - func: install dependencies - - func: bootstrap mongo-orchestration - - func: run tests - name: test-latest-server-ssl tags: - latest @@ -3180,66 +3046,6 @@ tasks: - func: install dependencies - func: bootstrap mongo-orchestration - func: run tests - - name: test-4.2-server-ssl - tags: - - '4.2' - - server - - ssl - commands: - - command: expansions.update - type: setup - params: - updates: - - {key: VERSION, value: '4.2'} - - {key: TOPOLOGY, value: server} - - {key: AUTH, value: auth} - - {key: SSL, value: ssl} - - {key: NODE_LTS_VERSION, value: '24'} - - {key: CLIENT_ENCRYPTION, value: 'true'} - - {key: TEST_CSFLE, value: 'true'} - - func: install dependencies - - func: bootstrap mongo-orchestration - - func: run tests - - name: test-4.2-replica_set-ssl - tags: - - '4.2' - - replica_set - - ssl - commands: - - command: expansions.update - type: setup - params: - updates: - - {key: VERSION, value: '4.2'} - - {key: TOPOLOGY, value: replica_set} - - {key: AUTH, value: auth} - - {key: SSL, value: ssl} - - {key: NODE_LTS_VERSION, value: '24'} - - {key: CLIENT_ENCRYPTION, value: 'true'} - - {key: TEST_CSFLE, value: 'true'} - - func: install dependencies - - func: bootstrap mongo-orchestration - - func: run tests - - name: test-4.2-sharded_cluster-ssl - tags: - - '4.2' - - sharded_cluster - - ssl - commands: - - command: expansions.update - type: setup - params: - updates: - - {key: VERSION, value: '4.2'} - - {key: TOPOLOGY, value: sharded_cluster} - - {key: AUTH, value: auth} - - {key: SSL, value: ssl} - - {key: NODE_LTS_VERSION, value: '24'} - - {key: CLIENT_ENCRYPTION, value: 'true'} - - {key: TEST_CSFLE, value: 'true'} - - func: install dependencies - - func: bootstrap mongo-orchestration - - func: run tests task_groups: - name: test_gcpkms_task_group setup_group_can_fail_task: true @@ -3547,9 +3353,6 @@ buildvariants: - test-4.4-server - test-4.4-replica_set - test-4.4-sharded_cluster - - test-4.2-server - - test-4.2-replica_set - - test-4.2-sharded_cluster - test-latest-server-v1-api - test-x509-authentication - test-atlas-connectivity @@ -3572,7 +3375,6 @@ buildvariants: - test-tls-support-6.0 - test-tls-support-5.0 - test-tls-support-4.4 - - test-tls-support-4.2 - name: rhel80-large-Node22 display_name: rhel8 Node22 run_on: rhel80-large @@ -3603,9 +3405,6 @@ buildvariants: - test-4.4-server - test-4.4-replica_set - test-4.4-sharded_cluster - - test-4.2-server - - test-4.2-replica_set - - test-4.2-sharded_cluster - test-latest-server-v1-api - test-x509-authentication - test-atlas-connectivity @@ -3628,7 +3427,6 @@ buildvariants: - test-tls-support-6.0 - test-tls-support-5.0 - test-tls-support-4.4 - - test-tls-support-4.2 - name: rhel80-large-Node24 display_name: rhel8 Node24 run_on: rhel80-large @@ -3658,9 +3456,6 @@ buildvariants: - test-4.4-server - test-4.4-replica_set - test-4.4-sharded_cluster - - test-4.2-server - - test-4.2-replica_set - - test-4.2-sharded_cluster - test-latest-server-v1-api - test-x509-authentication - test-atlas-connectivity @@ -3683,7 +3478,6 @@ buildvariants: - test-tls-support-6.0 - test-tls-support-5.0 - test-tls-support-4.4 - - test-tls-support-4.2 - name: rhel80-large-node-latest display_name: rhel8 Node Latest run_on: rhel80-large @@ -3713,9 +3507,6 @@ buildvariants: - test-4.4-server - test-4.4-replica_set - test-4.4-sharded_cluster - - test-4.2-server - - test-4.2-replica_set - - test-4.2-sharded_cluster - test-latest-server-v1-api - test-x509-authentication - test-atlas-connectivity @@ -3737,7 +3528,6 @@ buildvariants: - test-tls-support-6.0 - test-tls-support-5.0 - test-tls-support-4.4 - - test-tls-support-4.2 - name: windows-2022-latest-large-iron display_name: Windows Node20.19.0 run_on: windows-2022-latest-large @@ -3767,9 +3557,6 @@ buildvariants: - test-4.4-server - test-4.4-replica_set - test-4.4-sharded_cluster - - test-4.2-server - - test-4.2-replica_set - - test-4.2-sharded_cluster - test-latest-server-v1-api - test-socks5 - test-socks5-tls @@ -3781,7 +3568,6 @@ buildvariants: - test-tls-support-6.0 - test-tls-support-5.0 - test-tls-support-4.4 - - test-tls-support-4.2 - name: windows-2022-latest-large-Node22 display_name: Windows Node22 run_on: windows-2022-latest-large @@ -3812,9 +3598,6 @@ buildvariants: - test-4.4-server - test-4.4-replica_set - test-4.4-sharded_cluster - - test-4.2-server - - test-4.2-replica_set - - test-4.2-sharded_cluster - test-latest-server-v1-api - test-socks5 - test-socks5-tls @@ -3826,7 +3609,6 @@ buildvariants: - test-tls-support-6.0 - test-tls-support-5.0 - test-tls-support-4.4 - - test-tls-support-4.2 - name: windows-2022-latest-large-Node24 display_name: Windows Node24 run_on: windows-2022-latest-large @@ -3856,9 +3638,6 @@ buildvariants: - test-4.4-server - test-4.4-replica_set - test-4.4-sharded_cluster - - test-4.2-server - - test-4.2-replica_set - - test-4.2-sharded_cluster - test-latest-server-v1-api - test-socks5 - test-socks5-tls @@ -3870,7 +3649,6 @@ buildvariants: - test-tls-support-6.0 - test-tls-support-5.0 - test-tls-support-4.4 - - test-tls-support-4.2 - name: windows-2022-latest-large-node-latest display_name: Windows Node Latest run_on: windows-2022-latest-large @@ -3900,9 +3678,6 @@ buildvariants: - test-4.4-server - test-4.4-replica_set - test-4.4-sharded_cluster - - test-4.2-server - - test-4.2-replica_set - - test-4.2-sharded_cluster - test-latest-server-v1-api - test-socks5-tls - test-snappy-compression @@ -3913,7 +3688,6 @@ buildvariants: - test-tls-support-6.0 - test-tls-support-5.0 - test-tls-support-4.4 - - test-tls-support-4.2 - name: rhel8-node20.19.0-test-csfle-mongocryptd display_name: rhel 8 Node20.19.0 test mongocryptd run_on: rhel80-large @@ -3929,7 +3703,6 @@ buildvariants: - test-6.0-csfle-mongocryptd - test-5.0-csfle-mongocryptd - test-4.4-csfle-mongocryptd - - test-4.2-csfle-mongocryptd - name: rhel8-node24-test-csfle-mongocryptd display_name: rhel 8 Node24 test mongocryptd run_on: rhel80-large @@ -3945,7 +3718,6 @@ buildvariants: - test-6.0-csfle-mongocryptd - test-5.0-csfle-mongocryptd - test-4.4-csfle-mongocryptd - - test-4.2-csfle-mongocryptd - name: macos-14-arm64 display_name: MacOS 14 ARM Node24 run_on: macos-14-arm64 @@ -4052,9 +3824,6 @@ buildvariants: - test-4.4-server-noauth - test-4.4-replica_set-noauth - test-4.4-sharded_cluster-noauth - - test-4.2-server-noauth - - test-4.2-replica_set-noauth - - test-4.2-sharded_cluster-noauth - name: rhel8-test-lambda display_name: AWS Lambda handler tests run_on: rhel80-large diff --git a/src/cmap/auth/mongodb_aws.ts b/src/cmap/auth/mongodb_aws.ts index 422beb3dbd..56c1fca74d 100644 --- a/src/cmap/auth/mongodb_aws.ts +++ b/src/cmap/auth/mongodb_aws.ts @@ -1,11 +1,7 @@ import { type Binary, type BSONSerializeOptions, ByteUtils } from '../../bson'; import * as BSON from '../../bson'; -import { - MongoCompatibilityError, - MongoMissingCredentialsError, - MongoRuntimeError -} from '../../error'; -import { maxWireVersion, ns, randomBytes } from '../../utils'; +import { MongoMissingCredentialsError, MongoRuntimeError } from '../../error'; +import { ns, randomBytes } from '../../utils'; import { type AuthContext, AuthProvider } from './auth_provider'; import { type AWSCredentialProvider, @@ -45,12 +41,6 @@ export class MongoDBAWS extends AuthProvider { throw new MongoMissingCredentialsError('AuthContext must provide credentials.'); } - if (maxWireVersion(connection) < 9) { - throw new MongoCompatibilityError( - 'MONGODB-AWS authentication requires MongoDB version 4.4 or later' - ); - } - authContext.credentials = await makeTempCredentials( authContext.credentials, this.credentialFetcher diff --git a/src/cmap/connect.ts b/src/cmap/connect.ts index 35d3d622f9..5b6349affe 100644 --- a/src/cmap/connect.ts +++ b/src/cmap/connect.ts @@ -174,7 +174,7 @@ export async function performInitialHandshake( if (error instanceof MongoError) { error.addErrorLabel(MongoErrorLabel.HandshakeError); - if (needsRetryableWriteLabel(error, response.maxWireVersion, conn.description.type)) { + if (needsRetryableWriteLabel(error)) { error.addErrorLabel(MongoErrorLabel.RetryableWriteError); } } diff --git a/src/cmap/wire_protocol/constants.ts b/src/cmap/wire_protocol/constants.ts index aa689033e1..108b9fe4cd 100644 --- a/src/cmap/wire_protocol/constants.ts +++ b/src/cmap/wire_protocol/constants.ts @@ -1,8 +1,8 @@ -export const MIN_SUPPORTED_SERVER_VERSION = '4.2'; +export const MIN_SUPPORTED_SERVER_VERSION = '4.4'; export const MAX_SUPPORTED_SERVER_VERSION = '9.0'; export const MIN_SUPPORTED_SNAPSHOT_READS_WIRE_VERSION = 13; export const MIN_SUPPORTED_SNAPSHOT_READS_SERVER_VERSION = '5.0'; -export const MIN_SUPPORTED_WIRE_VERSION = 8; +export const MIN_SUPPORTED_WIRE_VERSION = 9; export const MAX_SUPPORTED_WIRE_VERSION = 29; export const MIN_SUPPORTED_QE_WIRE_VERSION = 21; export const MIN_SUPPORTED_QE_SERVER_VERSION = '7.0'; diff --git a/src/error.ts b/src/error.ts index e17e3e71eb..e442fefd86 100644 --- a/src/error.ts +++ b/src/error.ts @@ -3,7 +3,6 @@ import { type ClientBulkWriteError, type ClientBulkWriteResult } from './operations/client_bulk_write/common'; -import type { ServerType } from './sdam/common'; import type { TopologyVersion } from './sdam/server_description'; import type { TopologyDescription } from './sdam/topology_description'; @@ -1394,22 +1393,14 @@ const RETRYABLE_READ_ERROR_CODES = new Set([ // see: https://github.com/mongodb/specifications/blob/master/source/retryable-writes/retryable-writes.md#terms const RETRYABLE_WRITE_ERROR_CODES = RETRYABLE_READ_ERROR_CODES; -export function needsRetryableWriteLabel( - error: Error, - maxWireVersion: number, - serverType: ServerType -): boolean { +export function needsRetryableWriteLabel(error: Error): boolean { // pre-4.4 server, then the driver adds an error label for every valid case // execute operation will only inspect the label, code/message logic is handled here if (error instanceof MongoNetworkError) { return true; } - if (error instanceof MongoError) { - if ( - (maxWireVersion >= 9 || isRetryableWriteError(error)) && - !error.hasErrorLabel(MongoErrorLabel.HandshakeError) - ) { + if (isRetryableWriteError(error) && !error.hasErrorLabel(MongoErrorLabel.HandshakeError)) { // If we already have the error label no need to add it again. 4.4+ servers add the label. // In the case where we have a handshake error, need to fall down to the logic checking // the codes. @@ -1418,10 +1409,6 @@ export function needsRetryableWriteLabel( } if (error instanceof MongoWriteConcernError) { - if (serverType === 'Mongos' && maxWireVersion < 9) { - // use original top-level code from server response - return RETRYABLE_WRITE_ERROR_CODES.has(error.result.code ?? 0); - } const code = error.result.writeConcernError.code ?? Number(error.code); return RETRYABLE_WRITE_ERROR_CODES.has(Number.isNaN(code) ? 0 : code); } diff --git a/src/operations/delete.ts b/src/operations/delete.ts index 94b6435e1b..0141b5ce64 100644 --- a/src/operations/delete.ts +++ b/src/operations/delete.ts @@ -1,9 +1,9 @@ import type { Document } from '../bson'; import { type Connection } from '../cmap/connection'; import { MongoDBResponse } from '../cmap/wire_protocol/responses'; -import { MongoCompatibilityError, MongoServerError } from '../error'; +import { MongoServerError } from '../error'; import type { ClientSession } from '../sessions'; -import { maxWireVersion, type MongoDBCollectionNamespace, type MongoDBNamespace } from '../utils'; +import { type MongoDBCollectionNamespace, type MongoDBNamespace } from '../utils'; import { type WriteConcernOptions } from '../write_concern'; import { type CollationOptions, CommandOperation, type CommandOperationOptions } from './command'; import { Aspect, defineAspects, type Hint } from './operation'; @@ -65,7 +65,7 @@ export class DeleteOperation extends CommandOperation { return this.statements.every(op => (op.limit != null ? op.limit > 0 : true)); } - override buildCommandDocument(connection: Connection, _session?: ClientSession): Document { + override buildCommandDocument(_connection: Connection, _session?: ClientSession): Document { const options = this.options; const ordered = typeof options.ordered === 'boolean' ? options.ordered : true; @@ -85,15 +85,6 @@ export class DeleteOperation extends CommandOperation { command.comment = options.comment; } - const unacknowledgedWrite = this.writeConcern && this.writeConcern.w === 0; - if (unacknowledgedWrite && maxWireVersion(connection) < 9) { - if (this.statements.find((o: Document) => o.hint)) { - throw new MongoCompatibilityError( - `hint for the delete command is only supported on MongoDB 4.4+` - ); - } - } - return command; } } diff --git a/src/operations/find_and_modify.ts b/src/operations/find_and_modify.ts index a35e288dd4..e4fd97164c 100644 --- a/src/operations/find_and_modify.ts +++ b/src/operations/find_and_modify.ts @@ -6,7 +6,7 @@ import { MongoCompatibilityError, MongoInvalidArgumentError } from '../error'; import { ReadPreference } from '../read_preference'; import type { ClientSession } from '../sessions'; import { formatSort, type Sort, type SortForCmd } from '../sort'; -import { decorateWithCollation, hasAtomicOperators, maxWireVersion } from '../utils'; +import { decorateWithCollation, hasAtomicOperators } from '../utils'; import { type WriteConcern, type WriteConcernSettings } from '../write_concern'; import { CommandOperation, type CommandOperationOptions } from './command'; import { Aspect, defineAspects } from './operation'; @@ -146,7 +146,7 @@ export class FindAndModifyOperation extends CommandOperation { } override buildCommandDocument( - connection: Connection, + _connection: Connection, _session?: ClientSession ): Document & FindAndModifyCmdBase { const options = this.options; @@ -192,7 +192,7 @@ export class FindAndModifyOperation extends CommandOperation { if (options.hint) { const unacknowledgedWrite = this.writeConcern?.w === 0; - if (unacknowledgedWrite && maxWireVersion(connection) < 9) { + if (unacknowledgedWrite) { throw new MongoCompatibilityError( 'hint for the findAndModify command is only supported on MongoDB 4.4+' ); diff --git a/src/operations/get_more.ts b/src/operations/get_more.ts index 4e94020cd7..bdfcb458c6 100644 --- a/src/operations/get_more.ts +++ b/src/operations/get_more.ts @@ -4,7 +4,7 @@ import { CursorResponse } from '../cmap/wire_protocol/responses'; import { MongoRuntimeError } from '../error'; import type { Server, ServerCommandOptions } from '../sdam/server'; import { type TimeoutContext } from '../timeout'; -import { maxWireVersion, type MongoDBNamespace } from '../utils'; +import { type MongoDBNamespace } from '../utils'; import { AbstractOperation, Aspect, defineAspects, type OperationOptions } from './operation'; /** @internal */ @@ -55,7 +55,7 @@ export class GetMoreOperation extends AbstractOperation { return 'getMore' as const; } - override buildCommand(connection: Connection): Document { + override buildCommand(_connection: Connection): Document { if (this.cursorId == null || this.cursorId.isZero()) { throw new MongoRuntimeError('Unable to iterate cursor with no id'); } @@ -82,7 +82,7 @@ export class GetMoreOperation extends AbstractOperation { // we check for undefined specifically here to allow falsy values // eslint-disable-next-line no-restricted-syntax - if (this.options.comment !== undefined && maxWireVersion(connection) >= 9) { + if (this.options.comment !== undefined) { getMoreCmd.comment = this.options.comment; } diff --git a/src/operations/indexes.ts b/src/operations/indexes.ts index f6354dcf1a..ea4173f66b 100644 --- a/src/operations/indexes.ts +++ b/src/operations/indexes.ts @@ -3,7 +3,6 @@ import { type Connection } from '../cmap/connection'; import { CursorResponse, MongoDBResponse } from '../cmap/wire_protocol/responses'; import type { Collection } from '../collection'; import { type AbstractCursorOptions } from '../cursor/abstract_cursor'; -import { MongoCompatibilityError } from '../error'; import { type OneOrMore } from '../mongo_types'; import { isObject, maxWireVersion, type MongoDBNamespace } from '../utils'; import { @@ -299,20 +298,13 @@ export class CreateIndexesOperation extends CommandOperation { return 'createIndexes'; } - override buildCommandDocument(connection: Connection): Document { + override buildCommandDocument(_connection: Connection): Document { const options = this.options; const indexes = this.indexes; - const serverWireVersion = maxWireVersion(connection); - const cmd: Document = { createIndexes: this.collectionName, indexes }; if (options.commitQuorum != null) { - if (serverWireVersion < 9) { - throw new MongoCompatibilityError( - 'Option `commitQuorum` for `createIndexes` not supported on servers < 4.4' - ); - } cmd.commitQuorum = options.commitQuorum; } return cmd; diff --git a/src/operations/list_collections.ts b/src/operations/list_collections.ts index df38c954cb..b829af4e9b 100644 --- a/src/operations/list_collections.ts +++ b/src/operations/list_collections.ts @@ -4,7 +4,6 @@ import { CursorResponse, ExplainedCursorResponse } from '../cmap/wire_protocol/r import { type CursorTimeoutContext, type CursorTimeoutMode } from '../cursor/abstract_cursor'; import type { Db } from '../db'; import { type Abortable } from '../mongo_types'; -import { maxWireVersion } from '../utils'; import { CommandOperation, type CommandOperationOptions } from './command'; import { Aspect, defineAspects } from './operation'; @@ -63,7 +62,7 @@ export class ListCollectionsOperation extends CommandOperation { return 'listCollections' as const; } - override buildCommandDocument(connection: Connection): Document { + override buildCommandDocument(_connection: Connection): Document { const command: Document = { listCollections: 1, filter: this.filter, @@ -74,7 +73,7 @@ export class ListCollectionsOperation extends CommandOperation { // we check for undefined specifically here to allow falsy values // eslint-disable-next-line no-restricted-syntax - if (maxWireVersion(connection) >= 9 && this.options.comment !== undefined) { + if (this.options.comment !== undefined) { command.comment = this.options.comment; } diff --git a/src/operations/list_databases.ts b/src/operations/list_databases.ts index b9f4e97dda..1867471a6c 100644 --- a/src/operations/list_databases.ts +++ b/src/operations/list_databases.ts @@ -3,7 +3,7 @@ import type { Document } from '../bson'; import { MongoDBResponse } from '../cmap/wire_protocol/responses'; import type { Db } from '../db'; import type { ClientSession } from '../sessions'; -import { maxWireVersion, MongoDBNamespace } from '../utils'; +import { MongoDBNamespace } from '../utils'; import { CommandOperation, type CommandOperationOptions } from './command'; import { Aspect, defineAspects } from './operation'; @@ -40,7 +40,7 @@ export class ListDatabasesOperation extends CommandOperation= 9 && this.options.comment !== undefined) { + if (this.options.comment !== undefined) { cmd.comment = this.options.comment; } diff --git a/src/sdam/server.ts b/src/sdam/server.ts index 14b6455f1f..45c1c4127e 100644 --- a/src/sdam/server.ts +++ b/src/sdam/server.ts @@ -494,7 +494,7 @@ export class Server extends TypedEventEmitter { } else { if ( (isRetryableWritesEnabled(this.topology) || isTransactionCommand(cmd)) && - needsRetryableWriteLabel(error, maxWireVersion(this), this.description.type) && + needsRetryableWriteLabel(error) && !inActiveTransaction(session, cmd) ) { error.addErrorLabel(MongoErrorLabel.RetryableWriteError); diff --git a/src/utils.ts b/src/utils.ts index 50c0ddf0a2..d9a96115fc 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -343,9 +343,7 @@ export function maxWireVersion(handshakeAware?: Connection | Topology | Server): // object being checked will be a connection, and we will have a hello response on // it. For other cases, such as retryable writes, the object will be a server or // topology, and there will be no hello response on those objects, so we return - // the max wire version so we support retryability. Once we have a min supported - // wire version of 9, then the needsRetryableWriteLabel() check can remove the - // usage of passing the wire version into it. + // the max wire version so we support retryability. if (handshakeAware.loadBalanced) { return MAX_SUPPORTED_WIRE_VERSION; } diff --git a/test/unit/cmap/wire_protocol/constants.test.ts b/test/unit/cmap/wire_protocol/constants.test.ts index 1ca468c0c0..d659788625 100644 --- a/test/unit/cmap/wire_protocol/constants.test.ts +++ b/test/unit/cmap/wire_protocol/constants.test.ts @@ -9,8 +9,8 @@ import { describe('Wire Protocol Constants', function () { describe('MIN_SUPPORTED_SERVER_VERSION', function () { - it('returns 4.2', function () { - expect(MIN_SUPPORTED_SERVER_VERSION).to.equal('4.2'); + it('returns 4.4', function () { + expect(MIN_SUPPORTED_SERVER_VERSION).to.equal('4.4'); }); }); diff --git a/test/unit/error.test.ts b/test/unit/error.test.ts index 5315dcdea2..3dab63fd02 100644 --- a/test/unit/error.test.ts +++ b/test/unit/error.test.ts @@ -460,7 +460,6 @@ describe('MongoErrors', () => { // 9 - above server version 4.4 const ABOVE_4_4 = 9; - const BELOW_4_4 = 8; const tests: { description: string; @@ -468,36 +467,6 @@ describe('MongoErrors', () => { error: Error; maxWireVersion: number; }[] = [ - { - description: 'a plain error', - result: false, - error: new Error('do not retry me!'), - maxWireVersion: BELOW_4_4 - }, - { - description: 'a MongoError with no code nor label', - result: false, - error: new MongoError('do not retry me!'), - maxWireVersion: BELOW_4_4 - }, - { - description: 'network error', - result: true, - error: new MongoNetworkError('socket bad, try again'), - maxWireVersion: BELOW_4_4 - }, - { - description: 'a MongoWriteConcernError with a random label', - result: false, - error: new MongoWriteConcernError({ - writeConcernError: { - errmsg: 'random label', - code: 1 - }, - errorLabels: ['myLabel'] - }), - maxWireVersion: BELOW_4_4 - }, { description: 'a MongoWriteConcernError with a retryable code above server 4.4', result: false, @@ -509,29 +478,6 @@ describe('MongoErrors', () => { }), maxWireVersion: ABOVE_4_4 }, - { - description: 'a MongoWriteConcernError with a retryable code below server 4.4', - result: true, - error: new MongoWriteConcernError({ - writeConcernError: { - errmsg: 'code 262', - code: 262 - } - }), - maxWireVersion: BELOW_4_4 - }, - { - description: 'a MongoWriteConcernError with a RetryableWriteError label below server 4.4', - result: false, - error: new MongoWriteConcernError({ - writeConcernError: { - errmsg: 'code 1', - code: 1 - }, - errorLabels: ['RetryableWriteError'] - }), - maxWireVersion: BELOW_4_4 - }, { description: 'a MongoWriteConcernError with a RetryableWriteError label above server 4.4', result: false, @@ -557,9 +503,9 @@ describe('MongoErrors', () => { maxWireVersion: ABOVE_4_4 } ]; - for (const { description, result, error, maxWireVersion } of tests) { + for (const { description, result, error } of tests) { it(`${description} ${result ? 'needs' : 'does not need'} a retryable write label`, () => { - expect(needsRetryableWriteLabel(error, maxWireVersion)).to.be.equal(result); + expect(needsRetryableWriteLabel(error)).to.be.equal(result); }); } });