Skip to content

Remove support for MongoDB 4.0 #1663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 31, 2025
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
65 changes: 5 additions & 60 deletions .evergreen/.evg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ functions:
export AWS_TEMP_SESSION_TOKEN=$CSFLE_AWS_TEMP_SESSION_TOKEN
export CRYPT_SHARED_LIB_PATH=${CRYPT_SHARED_LIB_PATH}

AUTH="${AUTH}" SSL="${SSL}" MONGODB_URI="${MONGODB_URI}" SAFE_FOR_MULTI_MONGOS="${SAFE_FOR_MULTI_MONGOS}" TOPOLOGY="${TOPOLOGY}" \
AUTH="${AUTH}" SSL="${SSL}" MONGODB_URI="${MONGODB_URI}" TOPOLOGY="${TOPOLOGY}" \
COMPRESSOR="${COMPRESSOR}" JAVA_VERSION="${JAVA_VERSION}" REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
TESTS="${TESTS}" .evergreen/run-tests.sh

Expand Down Expand Up @@ -344,7 +344,7 @@ functions:
working_dir: "src"
script: |
${PREPARE_SHELL}
SCALA="${SCALA}" AUTH="${AUTH}" SSL="${SSL}" MONGODB_URI="${MONGODB_URI}" SAFE_FOR_MULTI_MONGOS="${SAFE_FOR_MULTI_MONGOS}" TOPOLOGY="${TOPOLOGY}" JAVA_VERSION="${JAVA_VERSION}" .evergreen/run-scala-tests.sh
SCALA="${SCALA}" AUTH="${AUTH}" SSL="${SSL}" MONGODB_URI="${MONGODB_URI}" TOPOLOGY="${TOPOLOGY}" JAVA_VERSION="${JAVA_VERSION}" .evergreen/run-scala-tests.sh

"run kotlin tests":
- command: shell.exec
Expand All @@ -353,7 +353,7 @@ functions:
working_dir: "src"
script: |
${PREPARE_SHELL}
AUTH="${AUTH}" SSL="${SSL}" MONGODB_URI="${MONGODB_URI}" SAFE_FOR_MULTI_MONGOS="${SAFE_FOR_MULTI_MONGOS}" TOPOLOGY="${TOPOLOGY}" JAVA_VERSION="${JAVA_VERSION}" .evergreen/run-kotlin-tests.sh
AUTH="${AUTH}" SSL="${SSL}" MONGODB_URI="${MONGODB_URI}" TOPOLOGY="${TOPOLOGY}" JAVA_VERSION="${JAVA_VERSION}" .evergreen/run-kotlin-tests.sh


"run socket tests":
Expand Down Expand Up @@ -599,16 +599,6 @@ functions:
LOGIN_CONTEXT_NAME=${LOGIN_CONTEXT_NAME} \
.evergreen/run-gssapi-auth-test.sh

"run mmapv1 storage test":
- command: shell.exec
type: test
params:
silent: true
working_dir: "src"
script: |
${PREPARE_SHELL}
PROJECT_DIRECTORY=${PROJECT_DIRECTORY} JAVA_VERSION=${JAVA_VERSION} TOPOLOGY=${TOPOLOGY} STORAGE_ENGINE=${STORAGE_ENGINE} MONGODB_URI="${MONGODB_URI}" .evergreen/run-mmapv1-storage-test.sh

run socks5 tests:
- command: shell.exec
type: test
Expand Down Expand Up @@ -1577,11 +1567,6 @@ tasks:
TEST_LAMBDA_DIRECTORY: ${PROJECT_DIRECTORY}/driver-lambda/
AWS_REGION: us-east-1

- name: "mmapv1-storage-test"
commands:
- func: "bootstrap mongo-orchestration"
- func: "run mmapv1 storage test"

- name: "test-kms-tls-invalid-cert"
tags: ["kms-tls"]
commands:
Expand Down Expand Up @@ -1717,55 +1702,30 @@ axes:
display_name: "latest"
variables:
VERSION: "latest"
# Multiple mongos instances can be specified in the connection string
# for this version.
SAFE_FOR_MULTI_MONGOS: true
- id: "8.0"
display_name: "8.0"
variables:
VERSION: "8.0"
# Multiple mongos instances can be specified in the connection string
# for this version.
SAFE_FOR_MULTI_MONGOS: true
- id: "7.0"
display_name: "7.0"
variables:
VERSION: "7.0"
# Multiple mongos instances can be specified in the connection string
# for this version.
SAFE_FOR_MULTI_MONGOS: true
- id: "6.0"
display_name: "6.0"
variables:
VERSION: "6.0"
# Multiple mongos instances can be specified in the connection string
# for this version.
SAFE_FOR_MULTI_MONGOS: true
- id: "5.0"
display_name: "5.0"
variables:
VERSION: "5.0"
# Multiple mongos instances can be specified in the connection string
# for this version.
SAFE_FOR_MULTI_MONGOS: true
- id: "4.4"
display_name: "4.4"
variables:
VERSION: "4.4"
# Multiple mongos instances can be specified in the connection string
# for this version.
SAFE_FOR_MULTI_MONGOS: true
- id: "4.2"
display_name: "4.2"
variables:
VERSION: "4.2"
# Multiple mongos instances can be specified in the connection string
# for this version.
SAFE_FOR_MULTI_MONGOS: true
- id: "4.0"
display_name: "4.0"
variables:
VERSION: "4.0"
- id: os
display_name: OS
values:
Expand Down Expand Up @@ -1886,15 +1846,6 @@ axes:
variables:
SCALA: "2.13"

# Choice of MongoDB storage engine
- id: storage-engine
display_name: Storage
values:
- id: mmapv1
display_name: MMAPv1
variables:
STORAGE_ENGINE: "mmapv1"

- id: api-version
display_name: API Version
values:
Expand Down Expand Up @@ -2201,7 +2152,7 @@ buildvariants:
- name: "test-bson-and-crypt"

- matrix_name: "tests-jdk8-unsecure"
matrix_spec: { auth: "noauth", ssl: "nossl", jdk: "jdk8", version: ["4.0", "4.2", "4.4", "5.0", "6.0", "7.0", "8.0", "latest"],
matrix_spec: { auth: "noauth", ssl: "nossl", jdk: "jdk8", version: ["4.2", "4.4", "5.0", "6.0", "7.0", "8.0", "latest"],
topology: "*", os: "linux" }
display_name: "${version} ${topology} ${auth} ${ssl} ${jdk} ${os} "
tags: ["tests-variant"]
Expand All @@ -2213,7 +2164,7 @@ buildvariants:

- matrix_name: "tests-jdk-secure"
matrix_spec: { auth: "auth", ssl: "ssl", jdk: [ "jdk8", "jdk17", "jdk21"],
version: ["4.0", "4.2", "4.4", "5.0", "6.0", "7.0", "8.0", "latest" ],
version: ["4.2", "4.4", "5.0", "6.0", "7.0", "8.0", "latest" ],
topology: "*", os: "linux" }
display_name: "${version} ${topology} ${auth} ${ssl} ${jdk} ${os} "
tags: ["tests-variant"]
Expand Down Expand Up @@ -2427,12 +2378,6 @@ buildvariants:
tasks:
- name: "publish-release"

- matrix_name: "tests-storage-engines"
matrix_spec: { auth: "noauth", ssl: "nossl", jdk: "jdk8", os: "linux", version: ["4.0"], topology: ["replicaset", "sharded-cluster"], storage-engine: "mmapv1" }
display_name: "${version} Storage ${storage-engine} ${jdk} ${os} ${topology}"
tasks:
- name: "mmapv1-storage-test"

- matrix_name: "kms-tls-test"
matrix_spec: { os: "linux", version: [ "5.0" ], topology: ["standalone"] }
display_name: "CSFLE KMS TLS"
Expand Down
5 changes: 1 addition & 4 deletions .evergreen/run-kotlin-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ AUTH=${AUTH:-noauth}
SSL=${SSL:-nossl}
MONGODB_URI=${MONGODB_URI:-}
TOPOLOGY=${TOPOLOGY:-standalone}
SAFE_FOR_MULTI_MONGOS=${SAFE_FOR_MULTI_MONGOS:-}

############################################
# Main Program #
Expand All @@ -27,9 +26,7 @@ if [ "$AUTH" != "noauth" ]; then
exit 1
fi

if [ "$SAFE_FOR_MULTI_MONGOS" == "true" ]; then
export MULTI_MONGOS_URI_SYSTEM_PROPERTY="-Dorg.mongodb.test.multi.mongos.uri=${MONGODB_URI}"
fi
export MULTI_MONGOS_URI_SYSTEM_PROPERTY="-Dorg.mongodb.test.multi.mongos.uri=${MONGODB_URI}"

./gradlew -version

Expand Down
24 changes: 0 additions & 24 deletions .evergreen/run-mmapv1-storage-test.sh

This file was deleted.

5 changes: 1 addition & 4 deletions .evergreen/run-scala-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ AUTH=${AUTH:-noauth}
SSL=${SSL:-nossl}
MONGODB_URI=${MONGODB_URI:-}
TOPOLOGY=${TOPOLOGY:-standalone}
SAFE_FOR_MULTI_MONGOS=${SAFE_FOR_MULTI_MONGOS:-}

############################################
# Main Program #
Expand All @@ -27,9 +26,7 @@ if [ "$AUTH" != "noauth" ]; then
exit 1
fi

if [ "$SAFE_FOR_MULTI_MONGOS" == "true" ]; then
export MULTI_MONGOS_URI_SYSTEM_PROPERTY="-Dorg.mongodb.test.multi.mongos.uri=${MONGODB_URI}"
fi
export MULTI_MONGOS_URI_SYSTEM_PROPERTY="-Dorg.mongodb.test.multi.mongos.uri=${MONGODB_URI}"

echo "Running scala tests with Scala $SCALA"

Expand Down
34 changes: 12 additions & 22 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,10 @@ provision_multi_mongos_uri_for_ssl () {
# Arguments for auth + SSL
if [ "$AUTH" != "noauth" ] || [ "$TOPOLOGY" == "replica_set" ]; then
export MONGODB_URI="${MONGODB_URI}&ssl=true&sslInvalidHostNameAllowed=true"
if [ "$SAFE_FOR_MULTI_MONGOS" == "true" ]; then
export MULTI_MONGOS_URI="${MULTI_MONGOS_URI}&ssl=true&sslInvalidHostNameAllowed=true"
fi
export MULTI_MONGOS_URI="${MULTI_MONGOS_URI}&ssl=true&sslInvalidHostNameAllowed=true"
else
export MONGODB_URI="${MONGODB_URI}/?ssl=true&sslInvalidHostNameAllowed=true"
if [ "$SAFE_FOR_MULTI_MONGOS" == "true" ]; then
export MULTI_MONGOS_URI="${MULTI_MONGOS_URI}/?ssl=true&sslInvalidHostNameAllowed=true"
fi
export MULTI_MONGOS_URI="${MULTI_MONGOS_URI}/?ssl=true&sslInvalidHostNameAllowed=true"
fi
}

Expand All @@ -85,13 +81,11 @@ provision_multi_mongos_uri_for_ssl () {

# Provision the correct connection string and set up SSL if needed
if [ "$TOPOLOGY" == "sharded_cluster" ]; then
if [ "$SAFE_FOR_MULTI_MONGOS" == "true" ]; then
if [ "$AUTH" = "auth" ]; then
export MULTI_MONGOS_URI="mongodb://bob:pwd123@localhost:27017,localhost:27018/?authSource=admin"
else
export MULTI_MONGOS_URI="${MONGODB_URI}"
fi
fi
if [ "$AUTH" = "auth" ]; then
export MULTI_MONGOS_URI="mongodb://bob:pwd123@localhost:27017,localhost:27018/?authSource=admin"
else
export MULTI_MONGOS_URI="${MONGODB_URI}"
fi

if [ "$AUTH" = "auth" ]; then
export MONGODB_URI="mongodb://bob:pwd123@localhost:27017/?authSource=admin"
Expand All @@ -107,12 +101,10 @@ if [ "$COMPRESSOR" != "" ]; then
export MONGODB_URI="${MONGODB_URI}/?compressors=${COMPRESSOR}"
fi

if [ "$SAFE_FOR_MULTI_MONGOS" == "true" ]; then
if [[ "$MULTI_MONGOS_URI" == *"?"* ]]; then
export MULTI_MONGOS_URI="${MULTI_MONGOS_URI}&compressors=${COMPRESSOR}"
else
export MULTI_MONGOS_URI="${MULTI_MONGOS_URI}/?compressors=${COMPRESSOR}"
fi
if [[ "$MULTI_MONGOS_URI" == *"?"* ]]; then
export MULTI_MONGOS_URI="${MULTI_MONGOS_URI}&compressors=${COMPRESSOR}"
else
export MULTI_MONGOS_URI="${MULTI_MONGOS_URI}/?compressors=${COMPRESSOR}"
fi
fi

Expand All @@ -123,9 +115,7 @@ if [ "$SSL" != "nossl" ]; then
provision_multi_mongos_uri_for_ssl
fi

if [ "$SAFE_FOR_MULTI_MONGOS" == "true" ]; then
export MULTI_MONGOS_URI_SYSTEM_PROPERTY="-Dorg.mongodb.test.multi.mongos.uri=${MULTI_MONGOS_URI}"
fi
export MULTI_MONGOS_URI_SYSTEM_PROPERTY="-Dorg.mongodb.test.multi.mongos.uri=${MULTI_MONGOS_URI}"

# For now it's sufficient to hard-code the API version to "1", since it's the only API version
if [ ! -z "$REQUIRE_API_VERSION" ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import static com.mongodb.assertions.Assertions.notNull;
import static com.mongodb.connection.ServerDescription.getDefaultMaxDocumentSize;
import static com.mongodb.internal.operation.ServerVersionHelper.UNKNOWN_WIRE_VERSION;

/**
* A description of a connection to a MongoDB server.
Expand Down Expand Up @@ -57,7 +58,7 @@ public class ConnectionDescription {
* @param serverId the server address
*/
public ConnectionDescription(final ServerId serverId) {
this(new ConnectionId(serverId), 0, ServerType.UNKNOWN, DEFAULT_MAX_WRITE_BATCH_SIZE,
this(new ConnectionId(serverId), UNKNOWN_WIRE_VERSION, ServerType.UNKNOWN, DEFAULT_MAX_WRITE_BATCH_SIZE,
getDefaultMaxDocumentSize(), DEFAULT_MAX_MESSAGE_SIZE, Collections.emptyList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public class ServerDescription {
* The minimum supported driver server version
* @since 3.8
*/
public static final String MIN_DRIVER_SERVER_VERSION = "3.6";
public static final String MIN_DRIVER_SERVER_VERSION = "4.2";
/**
* The minimum supported driver wire version
* @since 3.8
*/
public static final int MIN_DRIVER_WIRE_VERSION = 7;
public static final int MIN_DRIVER_WIRE_VERSION = 8;
/**
* The maximum supported driver wire version
* @since 3.8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
import static com.mongodb.internal.connection.ByteBufBsonDocument.createList;
import static com.mongodb.internal.connection.ByteBufBsonDocument.createOne;
import static com.mongodb.internal.connection.ReadConcernHelper.getReadConcernDocument;
import static com.mongodb.internal.operation.ServerVersionHelper.FOUR_DOT_TWO_WIRE_VERSION;
import static com.mongodb.internal.operation.ServerVersionHelper.FOUR_DOT_ZERO_WIRE_VERSION;
import static com.mongodb.internal.operation.ServerVersionHelper.UNKNOWN_WIRE_VERSION;

/**
* A command message that uses OP_MSG or OP_QUERY to send the command.
Expand Down Expand Up @@ -346,7 +345,6 @@ private List<BsonElement> getExtraElements(final OperationContext operationConte

assertFalse(sessionContext.hasActiveTransaction() && sessionContext.isSnapshot());
if (sessionContext.hasActiveTransaction()) {
checkServerVersionForTransactionSupport();
extraElements.add(new BsonElement("txnNumber", new BsonInt64(sessionContext.getTransactionNumber())));
if (firstMessageInTransaction) {
extraElements.add(new BsonElement("startTransaction", BsonBoolean.TRUE));
Expand Down Expand Up @@ -381,12 +379,6 @@ private void addServerApiElements(final List<BsonElement> extraElements) {
}
}

private void checkServerVersionForTransactionSupport() {
if (getSettings().getMaxWireVersion() < FOUR_DOT_TWO_WIRE_VERSION && getSettings().getServerType() == SHARD_ROUTER) {
throw new MongoClientException("Transactions are not supported by the MongoDB cluster to which this client is connected.");
}
}


private void addReadConcernDocument(final List<BsonElement> extraElements, final SessionContext sessionContext) {
BsonDocument readConcernDocument = getReadConcernDocument(sessionContext, getSettings().getMaxWireVersion());
Expand Down Expand Up @@ -416,7 +408,7 @@ private static OpCode getOpCode(final MessageSettings settings, final ClusterCon
}

private static boolean isServerVersionKnown(final MessageSettings settings) {
return settings.getMaxWireVersion() >= FOUR_DOT_ZERO_WIRE_VERSION;
return settings.getMaxWireVersion() != UNKNOWN_WIRE_VERSION;
}

@FunctionalInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private void handleException(final SdamIssue sdamIssue, final boolean beforeHand
}
if (sdamIssue.relatedToStateChange()) {
updateDescription(sdamIssue.serverDescription());
if (sdamIssue.serverIsLessThanVersionFourDotTwo() || sdamIssue.relatedToShutdown()) {
if (sdamIssue.relatedToShutdown()) {
connectionPool.invalidate(sdamIssue.exception().orElse(null));
}
serverMonitor.connect();
Expand All @@ -130,9 +130,6 @@ private void handleException(final SdamIssue sdamIssue, final boolean beforeHand
serverMonitor.cancelCurrentCheck();
} else if (sdamIssue.relatedToWriteConcern() || !sdamIssue.specific()) {
updateDescription(sdamIssue.serverDescription());
if (sdamIssue.serverIsLessThanVersionFourDotTwo()) {
connectionPool.invalidate(sdamIssue.exception().orElse(null));
}
serverMonitor.connect();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import com.mongodb.annotations.NotThreadSafe;
import com.mongodb.connection.ServerType;

import static com.mongodb.internal.operation.ServerVersionHelper.UNKNOWN_WIRE_VERSION;

/**
* The message settings
*
Expand Down Expand Up @@ -75,7 +77,7 @@ public static final class Builder {
private int maxDocumentSize = DEFAULT_MAX_DOCUMENT_SIZE;
private int maxMessageSize = DEFAULT_MAX_MESSAGE_SIZE;
private int maxBatchCount = DEFAULT_MAX_BATCH_COUNT;
private int maxWireVersion;
private int maxWireVersion = UNKNOWN_WIRE_VERSION;
private ServerType serverType;
private boolean sessionSupported;
private boolean cryptd;
Expand Down
Loading