From ac198af557410bce4809138c0089e1e56ff6db87 Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Wed, 9 Oct 2024 09:58:20 -0700 Subject: [PATCH] PYTHON-4729 Drop support for MongoDB 3.6 (#1905) --- .evergreen/config.yml | 52 ++++--------------- README.md | 2 +- doc/changelog.rst | 15 ++++++ doc/common-issues.rst | 6 +-- doc/examples/authentication.rst | 5 +- pymongo/asynchronous/collection.py | 5 -- pymongo/asynchronous/mongo_client.py | 5 +- pymongo/common.py | 4 +- pymongo/synchronous/collection.py | 5 -- pymongo/synchronous/mongo_client.py | 5 +- test/asynchronous/test_client.py | 8 +-- .../rs/null_election_id-pre-6.0.json | 2 +- test/mockupdb/test_auth_recovering_member.py | 4 +- test/mockupdb/test_cluster_time.py | 7 ++- test/mockupdb/test_cursor.py | 3 +- test/mockupdb/test_cursor_namespace.py | 5 +- test/mockupdb/test_getmore_sharded.py | 8 ++- test/mockupdb/test_handshake.py | 23 ++++++-- test/mockupdb/test_initial_ismaster.py | 10 ++-- test/mockupdb/test_list_indexes.py | 3 +- test/mockupdb/test_max_staleness.py | 6 ++- test/mockupdb/test_mixed_version_sharded.py | 2 - .../mockupdb/test_mongos_command_read_mode.py | 13 ++++- .../test_network_disconnect_primary.py | 9 +++- test/mockupdb/test_op_msg_read_preference.py | 9 ++-- test/mockupdb/test_query_read_pref_sharded.py | 8 ++- test/mockupdb/test_reset_and_request_check.py | 6 ++- test/mockupdb/test_slave_okay_rs.py | 10 +++- test/mockupdb/test_slave_okay_sharded.py | 7 ++- test/mockupdb/test_slave_okay_single.py | 3 +- test/test_client.py | 8 +-- test/test_discovery_and_monitoring.py | 7 ++- test/test_server_description.py | 4 +- test/test_topology.py | 50 +++++++++++++----- test/utils_selection_tests.py | 4 +- 35 files changed, 191 insertions(+), 132 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 7fb48c805..a345e4f5b 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -1014,33 +1014,6 @@ tasks: TOPOLOGY: "server" - func: "run doctests" - - name: "test-3.6-standalone" - tags: ["3.6", "standalone"] - commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "3.6" - TOPOLOGY: "server" - - func: "run tests" - - - name: "test-3.6-replica_set" - tags: ["3.6", "replica_set"] - commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "3.6" - TOPOLOGY: "replica_set" - - func: "run tests" - - - name: "test-3.6-sharded_cluster" - tags: ["3.6", "sharded_cluster"] - commands: - - func: "bootstrap mongo-orchestration" - vars: - VERSION: "3.6" - TOPOLOGY: "sharded_cluster" - - func: "run tests" - - name: "test-4.0-standalone" tags: ["4.0", "standalone"] commands: @@ -2186,10 +2159,6 @@ axes: - id: mongodb-version display_name: "MongoDB" values: - - id: "3.6" - display_name: "MongoDB 3.6" - variables: - VERSION: "3.6" - id: "4.0" display_name: "MongoDB 4.0" variables: @@ -2490,7 +2459,6 @@ buildvariants: - ".4.4" - ".4.2" - ".4.0" - - ".3.6" - matrix_name: "test-macos-arm64" matrix_spec: @@ -2562,7 +2530,6 @@ buildvariants: - ".4.4" - ".4.2" - ".4.0" - - ".3.6" - matrix_name: "tests-pyopenssl" matrix_spec: @@ -2657,19 +2624,22 @@ buildvariants: display_name: "${compression} ${c-extensions} ${python-version} ${platform}" tasks: - "test-latest-standalone" + - "test-8.0-standalone" + - "test-7.0-standalone" + - "test-6.0-standalone" - "test-5.0-standalone" - "test-4.4-standalone" - "test-4.2-standalone" + - "test-4.0-standalone" rules: - # Server versions 3.6 and 4.0 support snappy and zlib. + # Server version 4.0 supports snappy and zlib but not zstd. - if: python-version: "*" c-extensions: "*" - compression: ["snappy", "zlib"] + compression: ["zstd"] then: - add_tasks: + remove_tasks: - "test-4.0-standalone" - - "test-3.6-standalone" - matrix_name: "tests-python-version-green-framework-rhel8" matrix_spec: @@ -2734,7 +2704,7 @@ buildvariants: matrix_spec: platform: rhel8 storage-engine: "*" - python-version: 3.9 + python-version: "3.9" display_name: "Storage ${storage-engine} ${python-version} ${platform}" rules: - if: @@ -2751,7 +2721,6 @@ buildvariants: - "test-4.4-standalone" - "test-4.2-standalone" - "test-4.0-standalone" - - "test-3.6-standalone" - if: # MongoDB 4.2 drops support for MMAPv1 platform: rhel8 @@ -2761,8 +2730,6 @@ buildvariants: add_tasks: - "test-4.0-standalone" - "test-4.0-replica_set" - - "test-3.6-standalone" - - "test-3.6-replica_set" # enableTestCommands=0 tests on RHEL 8.4 (x86_64) with Python 3.9. - matrix_name: "test-disableTestCommands" @@ -2881,6 +2848,9 @@ buildvariants: tasks: # Versioned API was introduced in MongoDB 4.7 - "test-latest-standalone" + - "test-8.0-standalone" + - "test-7.0-standalone" + - "test-6.0-standalone" - "test-5.0-standalone" - matrix_name: "ocsp-test" diff --git a/README.md b/README.md index 9b5aa33f7..f5e2cdf46 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ a native Python driver for MongoDB. The `gridfs` package is a [gridfs](https://github.com/mongodb/specifications/blob/master/source/gridfs/gridfs-spec.rst/) implementation on top of `pymongo`. -PyMongo supports MongoDB 3.6, 4.0, 4.2, 4.4, 5.0, 6.0, 7.0, and 8.0. +PyMongo supports MongoDB 4.0, 4.2, 4.4, 5.0, 6.0, 7.0, and 8.0. ## Support / Feedback diff --git a/doc/changelog.rst b/doc/changelog.rst index a73a89a0e..6a118f56c 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -5,6 +5,21 @@ Changes in Version 4.11.0 ------------------------- .. warning:: PyMongo 4.11 drops support for Python 3.8: Python 3.9+ or PyPy 3.9+ is now required. +.. warning:: PyMongo 4.11 drops support for MongoDB 3.6. PyMongo now supports MongoDB 4.0+. + Driver support for MongoDB 3.6 reached end of life in April 2024. + +PyMongo 4.11 brings a number of changes including: + +- Dropped support for Python 3.8. +- Dropped support for MongoDB 3.6. + +Issues Resolved +............... + +See the `PyMongo 4.11 release notes in JIRA`_ for the list of resolved issues +in this release. + +.. _PyMongo 4.11 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=40784 Changes in Version 4.10.1 ------------------------- diff --git a/doc/common-issues.rst b/doc/common-issues.rst index 3d2d06a5a..b300bac78 100644 --- a/doc/common-issues.rst +++ b/doc/common-issues.rst @@ -6,14 +6,14 @@ Also see the :ref:`TLSErrors` section. Server reports wire version X, PyMongo requires Y ------------------------------------------------- -When one attempts to connect to a <=3.4 version server, PyMongo will throw the following error:: +When one attempts to connect to a <=3.6 version server, PyMongo will throw the following error:: >>> client.admin.command('ping') ... - pymongo.errors.ConfigurationError: Server at localhost:27017 reports wire version 5, but this version of PyMongo requires at least 6 (MongoDB 3.6). + pymongo.errors.ConfigurationError: Server at localhost:27017 reports wire version 6, but this version of PyMongo requires at least 7 (MongoDB 4.0). This is caused by the driver being too new for the server it is being run against. -To resolve this issue either upgrade your database to version >= 3.6 or downgrade to PyMongo 3.x which supports MongoDB >= 2.6. +To resolve this issue either upgrade your database to version >= 4.0 or downgrade to an early version of PyMongo which supports MongoDB < 4.0. 'Cursor' object has no attribute '_Cursor__killed' diff --git a/doc/examples/authentication.rst b/doc/examples/authentication.rst index 24b3cff8d..6c89910f3 100644 --- a/doc/examples/authentication.rst +++ b/doc/examples/authentication.rst @@ -97,9 +97,8 @@ the "MongoDB Challenge-Response" protocol:: Default Authentication Mechanism -------------------------------- -If no mechanism is specified, PyMongo automatically SCRAM-SHA-1 when connected -to MongoDB 3.6 and negotiates the mechanism to use (SCRAM-SHA-1 -or SCRAM-SHA-256) when connected to MongoDB 4.0+. +If no mechanism is specified, PyMongo automatically negotiates the mechanism to use (SCRAM-SHA-1 +or SCRAM-SHA-256) with the MongoDB server. Default Database and "authSource" --------------------------------- diff --git a/pymongo/asynchronous/collection.py b/pymongo/asynchronous/collection.py index 5abc41a7e..4ddcbab4d 100644 --- a/pymongo/asynchronous/collection.py +++ b/pymongo/asynchronous/collection.py @@ -1960,20 +1960,15 @@ class AsyncCollection(common.BaseObject, Generic[_DocumentType]): collation: Optional[Collation], ) -> int: """Internal count command helper.""" - # XXX: "ns missing" checks can be removed when we drop support for - # MongoDB 3.0, see SERVER-17051. res = await self._command( conn, cmd, read_preference=read_preference, - allowable_errors=["ns missing"], codec_options=self._write_response_codec_options, read_concern=self.read_concern, collation=collation, session=session, ) - if res.get("errmsg", "") == "ns missing": - return 0 return int(res["n"]) async def _aggregate_one_result( diff --git a/pymongo/asynchronous/mongo_client.py b/pymongo/asynchronous/mongo_client.py index 814c60456..bfae302da 100644 --- a/pymongo/asynchronous/mongo_client.py +++ b/pymongo/asynchronous/mongo_client.py @@ -498,9 +498,8 @@ class AsyncMongoClient(common.BaseObject, Generic[_DocumentType]): - `authSource`: The database to authenticate on. Defaults to the database specified in the URI, if provided, or to "admin". - `authMechanism`: See :data:`~pymongo.auth.MECHANISMS` for options. - If no mechanism is specified, PyMongo automatically SCRAM-SHA-1 - when connected to MongoDB 3.6 and negotiates the mechanism to use - (SCRAM-SHA-1 or SCRAM-SHA-256) when connected to MongoDB 4.0+. + If no mechanism is specified, PyMongo automatically negotiates the + mechanism to use (SCRAM-SHA-1 or SCRAM-SHA-256) with the MongoDB server. - `authMechanismProperties`: Used to specify authentication mechanism specific options. To specify the service name for GSSAPI authentication pass authMechanismProperties='SERVICE_NAME: int: """Internal count command helper.""" - # XXX: "ns missing" checks can be removed when we drop support for - # MongoDB 3.0, see SERVER-17051. res = self._command( conn, cmd, read_preference=read_preference, - allowable_errors=["ns missing"], codec_options=self._write_response_codec_options, read_concern=self.read_concern, collation=collation, session=session, ) - if res.get("errmsg", "") == "ns missing": - return 0 return int(res["n"]) def _aggregate_one_result( diff --git a/pymongo/synchronous/mongo_client.py b/pymongo/synchronous/mongo_client.py index b2dff5b4a..1351cb200 100644 --- a/pymongo/synchronous/mongo_client.py +++ b/pymongo/synchronous/mongo_client.py @@ -496,9 +496,8 @@ class MongoClient(common.BaseObject, Generic[_DocumentType]): - `authSource`: The database to authenticate on. Defaults to the database specified in the URI, if provided, or to "admin". - `authMechanism`: See :data:`~pymongo.auth.MECHANISMS` for options. - If no mechanism is specified, PyMongo automatically SCRAM-SHA-1 - when connected to MongoDB 3.6 and negotiates the mechanism to use - (SCRAM-SHA-1 or SCRAM-SHA-256) when connected to MongoDB 4.0+. + If no mechanism is specified, PyMongo automatically negotiates the + mechanism to use (SCRAM-SHA-1 or SCRAM-SHA-256) with the MongoDB server. - `authMechanismProperties`: Used to specify authentication mechanism specific options. To specify the service name for GSSAPI authentication pass authMechanismProperties='SERVICE_NAME: