Compare commits

...

20 Commits

Author SHA1 Message Date
mongodb-dbx-release-bot[bot]
0450126a10
BUMP 4.11.4.dev0
Signed-off-by: mongodb-dbx-release-bot[bot] <167856002+mongodb-dbx-release-bot[bot]@users.noreply.github.com>
2025-03-18 12:47:42 +00:00
mongodb-dbx-release-bot[bot]
82407a56c0
BUMP 4.11.3
Signed-off-by: mongodb-dbx-release-bot[bot] <167856002+mongodb-dbx-release-bot[bot]@users.noreply.github.com>
2025-03-18 12:28:59 +00:00
Steven Silvester
d15d5e7445
Prepare for 4.11.3 release (#2208) 2025-03-18 07:27:43 -05:00
mongodb-drivers-pr-bot[bot]
c2bf5e455d
PYTHON-5198 Fix test_03_invalid_keyid (#2195) [v4.11] (#2198)
Co-authored-by: Shane Harvey <shnhrv@gmail.com>
2025-03-13 14:34:35 -07:00
mongodb-drivers-pr-bot[bot]
dc73514cba
PYTHON-5202 WaitQueueTimeoutError should not clear the pool (#2192) [v4.11] (#2196)
Co-authored-by: Shane Harvey <shnhrv@gmail.com>
2025-03-12 12:21:42 -07:00
Steven Silvester
112e29b30f
PYTHON-5131 [v4.11] Migrate off of Ubuntu 20.04 GitHub Actions Runners (#2182) 2025-03-05 17:08:12 -06:00
mongodb-dbx-release-bot[bot]
ca0ed96eca
BUMP 4.11.3.dev0
Signed-off-by: mongodb-dbx-release-bot[bot] <167856002+mongodb-dbx-release-bot[bot]@users.noreply.github.com>
2025-03-03 21:35:28 +00:00
mongodb-dbx-release-bot[bot]
c27fa509fd
BUMP 4.11.2
Signed-off-by: mongodb-dbx-release-bot[bot] <167856002+mongodb-dbx-release-bot[bot]@users.noreply.github.com>
2025-03-03 21:16:35 +00:00
mongodb-dbx-release-bot[bot]
c17011ae7f
BUMP 4.11.1
Signed-off-by: mongodb-dbx-release-bot[bot] <167856002+mongodb-dbx-release-bot[bot]@users.noreply.github.com>
2025-03-03 21:14:04 +00:00
Shane Harvey
0fa3475835
PYTHON-5155 Use dochub link for fork warning (#2173) [v4.11] (#2174) 2025-03-03 12:27:35 -08:00
Shane Harvey
315f3cd1b2
PYTHON-5166 Allow Database.command to run bulkWrite commands (#2164) [v4.11] (#2172) 2025-03-03 11:30:12 -08:00
mongodb-dbx-release-bot[bot]
736aa56be1
BUMP 4.11.2.dev0
Signed-off-by: mongodb-dbx-release-bot[bot] <167856002+mongodb-dbx-release-bot[bot]@users.noreply.github.com>
2025-02-10 20:01:47 +00:00
mongodb-dbx-release-bot[bot]
d175edff9f
BUMP 4.11.1
Signed-off-by: mongodb-dbx-release-bot[bot] <167856002+mongodb-dbx-release-bot[bot]@users.noreply.github.com>
2025-02-10 19:42:27 +00:00
Steven Silvester
4a6aae8f43
PYTHON-5125 Prep for 4.11.1 release (#2137) 2025-02-10 13:41:26 -06:00
Steven Silvester
c83f34c826
PYTHON-5047 Do not run nightly release check on forks (#2134)
(cherry picked from commit a641337b5c)
2025-02-06 13:59:50 -06:00
Steven Silvester
e15b820f71
PYTHON-5058 Restore alternate architecture builds (#2133)
(cherry picked from commit 041edbecba)
2025-02-06 13:43:14 -06:00
Jib
3c9a248bba
Update ReadTheDocs to include django-mongodb-backend (#2084)
(cherry picked from commit 3b5788906d)
2025-02-06 13:43:07 -06:00
Steven Silvester
f1a8af160d
PYTHON-5047 Fix dry run logic in releases yet again (#2098)
(cherry picked from commit 34ae214e33)
2025-02-06 13:42:57 -06:00
Noah Stapp
d0301307a0
PYTHON-5112 - Fix just install (#2095)
(cherry picked from commit 1784e2c4b9)
2025-02-06 13:42:45 -06:00
Steven Silvester
ed21a18172
PYTHON-5047 Fix dry run logic in releases again (#2092)
(cherry picked from commit b4e32a1d83)
2025-02-06 13:42:35 -06:00
17 changed files with 138 additions and 38 deletions

View File

@ -30,8 +30,8 @@ if [ ! -d $BIN_DIR ]; then
fi
export UV_PYTHON=${PYTHON_BINARY}
echo "export UV_PYTHON=$UV_PYTHON" >> $HERE/env.sh
echo "Using python $UV_PYTHON"
fi
echo "Using python $UV_PYTHON"
uv sync --frozen
uv run --frozen --with pip pip install -e .
echo "Setting up python environment... done."

View File

@ -34,12 +34,11 @@ jobs:
# Github Actions doesn't support pairing matrix values together, let's improvise
# https://github.com/github/feedback/discussions/7835#discussioncomment-1769026
buildplat:
- [ubuntu-20.04, "manylinux_x86_64", "cp3*-manylinux_x86_64"]
- [ubuntu-24.04-arm, "manylinux_aarch64", "cp3*-manylinux_aarch64"]
# Disabled pending PYTHON-5058
# - [ubuntu-24.04, "manylinux_ppc64le", "cp3*-manylinux_ppc64le"]
# - [ubuntu-24.04, "manylinux_s390x", "cp3*-manylinux_s390x"]
- [ubuntu-20.04, "manylinux_i686", "cp3*-manylinux_i686"]
- [ubuntu-latest, "manylinux_x86_64", "cp3*-manylinux_x86_64"]
- [ubuntu-latest, "manylinux_aarch64", "cp3*-manylinux_aarch64"]
- [ubuntu-latest, "manylinux_ppc64le", "cp3*-manylinux_ppc64le"]
- [ubuntu-latest, "manylinux_s390x", "cp3*-manylinux_s390x"]
- [ubuntu-latest, "manylinux_i686", "cp3*-manylinux_i686"]
- [windows-2019, "win_amd6", "cp3*-win_amd64"]
- [windows-2019, "win32", "cp3*-win32"]
- [macos-14, "macos", "cp*-macosx_*"]
@ -63,6 +62,10 @@ jobs:
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
# setup-qemu-action by default uses `tonistiigi/binfmt:latest` image,
# which is out of date. This causes seg faults during build.
# Here we manually fix the version.
image: tonistiigi/binfmt:qemu-v8.1.5
platforms: all
- name: Install cibuildwheel

View File

@ -20,10 +20,12 @@ env:
# Changes per repo
PRODUCT_NAME: PyMongo
# Changes per branch
SILK_ASSET_GROUP: mongodb-python-driver
EVERGREEN_PROJECT: mongo-python-driver
SILK_ASSET_GROUP: mongodb-python-driver-4.11
EVERGREEN_PROJECT: mongo-python-driver-release
# Constant
DRY_RUN: ${{ inputs.dry_run == 'true' }}
# inputs will be empty on a scheduled run. so, we only set dry_run
# to 'false' when the input is set to 'false'.
DRY_RUN: ${{ ! contains(inputs.dry_run, 'false') }}
FOLLOWING_VERSION: ${{ inputs.following_version || '' }}
VERSION: ${{ inputs.version || '10.10.10.10' }}
@ -35,6 +37,7 @@ jobs:
pre-publish:
environment: release
runs-on: ubuntu-latest
if: github.repository_owner == 'mongodb' || github.event_name == 'workflow_dispatch'
permissions:
id-token: write
contents: write

View File

@ -54,7 +54,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
os: [ubuntu-latest]
python-version: ["3.9", "pypy-3.10", "3.13", "3.13t"]
name: CPython ${{ matrix.python-version }}-${{ matrix.os }}
steps:

View File

@ -1,7 +1,41 @@
Changelog
=========
Changes in Version 4.11.0 (YYYY/MM/DD)
Changes in Version 4.11.3 (2025/03/17)
--------------------------------------
Version 4.11.3 is a bug fix release.
- Fixed a bug where a ``WaitQueueTimeoutError`` would cause the connection pool to be cleared.
Issues Resolved
...............
See the `PyMongo 4.11.3 release notes in JIRA`_ for the list of resolved issues in this release.
.. _PyMongo 4.11.3 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=42695
Changes in Version 4.11.2 (2025/03/03)
--------------------------------------
Version 4.11.2 is a bug fix release.
- Fixed a bug where :meth:`~pymongo.database.Database.command` would fail when attempting to run the bulkWrite command.
Issues Resolved
...............
See the `PyMongo 4.11.2 release notes in JIRA`_ for the list of resolved issues in this release.
.. _PyMongo 4.11.2 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=42506
Changes in Version 4.11.1 (2025/02/10)
--------------------------------------
- Fixed support for prebuilt ``ppc64le`` and ``s390x`` wheels.
Changes in Version 4.11.0 (2025/01/28)
--------------------------------------
.. warning:: PyMongo 4.11 drops support for Python 3.8 and PyPy 3.9: Python 3.9+ or PyPy 3.10+ is now required.
@ -180,7 +214,7 @@ PyMongo 4.9 brings a number of improvements including:
unction-as-a-service (FaaS) like AWS Lambda, Google Cloud Functions, and Microsoft Azure Functions.
On some FaaS systems, there is a ``fork()`` operation at function
startup. By delaying the connection to the first operation, we avoid a deadlock. See
`Is PyMongo Fork-Safe`_ for more information.
:ref:`pymongo-fork-safe` for more information.
Issues Resolved
@ -189,7 +223,6 @@ Issues Resolved
See the `PyMongo 4.9 release notes in JIRA`_ for the list of resolved issues
in this release.
.. _Is PyMongo Fork-Safe : https://www.mongodb.com/docs/languages/python/pymongo-driver/current/faq/#is-pymongo-fork-safe-
.. _PyMongo 4.9 release notes in JIRA: https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10004&version=39940

View File

@ -67,6 +67,14 @@ uMongo
mongomock. The source `is available on GitHub
<https://github.com/Scille/umongo>`_
Django MongoDB Backend
`Django MongoDB Backend <https://django-mongodb-backend.readthedocs.io>`_ is a
database backend library specifically made for Django. The integration takes
advantage of MongoDB's unique document model capabilities, which align
naturally with Django's philosophy of simplified data modeling and
reduced development complexity. The source is available
`on GitHub <https://github.com/mongodb-labs/django-mongodb-backend>`_.
No longer maintained
""""""""""""""""""""

View File

@ -18,7 +18,7 @@ from __future__ import annotations
import re
from typing import List, Tuple, Union
__version__ = "4.11"
__version__ = "4.11.4.dev0"
def get_version_tuple(version: str) -> Tuple[Union[int, str], ...]:

View File

@ -40,6 +40,7 @@ from pymongo.errors import (
OperationFailure,
PyMongoError,
ServerSelectionTimeoutError,
WaitQueueTimeoutError,
WriteError,
)
from pymongo.hello import Hello
@ -232,9 +233,7 @@ class Topology:
warnings.warn( # type: ignore[call-overload] # noqa: B028
"AsyncMongoClient opened before fork. May not be entirely fork-safe, "
"proceed with caution. See PyMongo's documentation for details: "
"https://www.mongodb.com/docs/languages/"
"python/pymongo-driver/current/faq/"
"#is-pymongo-fork-safe-",
"https://dochub.mongodb.org/core/pymongo-fork-deadlock",
**kwargs,
)
async with self._lock:
@ -879,6 +878,8 @@ class Topology:
# Clear the pool.
await server.reset(service_id)
elif isinstance(error, ConnectionFailure):
if isinstance(error, WaitQueueTimeoutError):
return
# "Client MUST replace the server's description with type Unknown
# ... MUST NOT request an immediate check of the server."
if not self._settings.load_balanced:

View File

@ -105,7 +105,7 @@ _FIELD_MAP = {
"insert": "documents",
"update": "updates",
"delete": "deletes",
"bulkWrite": "bulkWrite",
"bulkWrite": "ops",
}
_UNICODE_REPLACE_CODEC_OPTIONS: CodecOptions[Mapping[str, Any]] = CodecOptions(

View File

@ -36,6 +36,7 @@ from pymongo.errors import (
OperationFailure,
PyMongoError,
ServerSelectionTimeoutError,
WaitQueueTimeoutError,
WriteError,
)
from pymongo.hello import Hello
@ -232,9 +233,7 @@ class Topology:
warnings.warn( # type: ignore[call-overload] # noqa: B028
"MongoClient opened before fork. May not be entirely fork-safe, "
"proceed with caution. See PyMongo's documentation for details: "
"https://www.mongodb.com/docs/languages/"
"python/pymongo-driver/current/faq/"
"#is-pymongo-fork-safe-",
"https://dochub.mongodb.org/core/pymongo-fork-deadlock",
**kwargs,
)
with self._lock:
@ -877,6 +876,8 @@ class Topology:
# Clear the pool.
server.reset(service_id)
elif isinstance(error, ConnectionFailure):
if isinstance(error, WaitQueueTimeoutError):
return
# "Client MUST replace the server's description with type Unknown
# ... MUST NOT request an immediate check of the server."
if not self._settings.load_balanced:

View File

@ -1,11 +1,12 @@
{
"metadata": {
"timestamp": "2024-05-02T17:36:12.698229+00:00"
},
"components": [],
"serialNumber": "urn:uuid:9876a8a6-060e-486f-b128-910aecf0fe7b",
"version": 1,
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
"bomFormat": "CycloneDX",
"specVersion": "1.5"
}
"metadata": {
"timestamp": "2025-02-06T23:38:31.503894+00:00"
},
"components": [],
"serialNumber": "urn:uuid:04738005-86f1-4d21-866f-ce4560f03f00",
"version": 1,
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
"bomFormat": "CycloneDX",
"specVersion": "1.5",
"vulnerabilities": []
}

View File

@ -111,6 +111,7 @@ from pymongo.errors import (
NetworkTimeout,
OperationFailure,
ServerSelectionTimeoutError,
WaitQueueTimeoutError,
WriteConcernError,
)
from pymongo.monitoring import ServerHeartbeatListener, ServerHeartbeatStartedEvent
@ -1311,8 +1312,16 @@ class TestClient(AsyncIntegrationTest):
self.assertAlmostEqual(30, client.options.server_selection_timeout)
async def test_waitQueueTimeoutMS(self):
client = await self.async_rs_or_single_client(waitQueueTimeoutMS=2000)
self.assertEqual((await async_get_pool(client)).opts.wait_queue_timeout, 2)
listener = CMAPListener()
client = await self.async_rs_or_single_client(
waitQueueTimeoutMS=10, maxPoolSize=1, event_listeners=[listener]
)
pool = await async_get_pool(client)
self.assertEqual(pool.opts.wait_queue_timeout, 0.01)
async with pool.checkout():
with self.assertRaises(WaitQueueTimeoutError):
await client.test.command("ping")
self.assertFalse(listener.events_by_type(monitoring.PoolClearedEvent))
async def test_socketKeepAlive(self):
pool = await async_get_pool(self.client)

View File

@ -430,6 +430,21 @@ class TestDatabase(AsyncIntegrationTest):
for doc in result["cursor"]["firstBatch"]:
self.assertTrue(isinstance(doc["r"], Regex))
async def test_command_bulkWrite(self):
# Ensure bulk write commands can be run directly via db.command().
if async_client_context.version.at_least(8, 0):
await self.client.admin.command(
{
"bulkWrite": 1,
"nsInfo": [{"ns": self.db.test.full_name}],
"ops": [{"insert": 0, "document": {}}],
}
)
await self.db.command({"insert": "test", "documents": [{}]})
await self.db.command({"update": "test", "updates": [{"q": {}, "u": {"$set": {"x": 1}}}]})
await self.db.command({"delete": "test", "deletes": [{"q": {}, "limit": 1}]})
await self.db.test.drop()
async def test_cursor_command(self):
db = self.client.pymongo_test
await db.test.drop()

View File

@ -2982,9 +2982,10 @@ class TestAutomaticDecryptionKeys(AsyncEncryptionIntegrationTest):
)
async def test_03_invalid_keyid(self):
# checkAuthForCreateCollection can be removed when SERVER-102101 is fixed.
with self.assertRaisesRegex(
EncryptedCollectionError,
"create.encryptedFields.fields.keyId' is the wrong type 'bool', expected type 'binData",
"(create|checkAuthForCreateCollection).encryptedFields.fields.keyId' is the wrong type 'bool', expected type 'binData",
):
await self.client_encryption.create_encrypted_collection(
database=self.db,

View File

@ -100,6 +100,7 @@ from pymongo.errors import (
NetworkTimeout,
OperationFailure,
ServerSelectionTimeoutError,
WaitQueueTimeoutError,
WriteConcernError,
)
from pymongo.monitoring import ServerHeartbeatListener, ServerHeartbeatStartedEvent
@ -1270,8 +1271,16 @@ class TestClient(IntegrationTest):
self.assertAlmostEqual(30, client.options.server_selection_timeout)
def test_waitQueueTimeoutMS(self):
client = self.rs_or_single_client(waitQueueTimeoutMS=2000)
self.assertEqual((get_pool(client)).opts.wait_queue_timeout, 2)
listener = CMAPListener()
client = self.rs_or_single_client(
waitQueueTimeoutMS=10, maxPoolSize=1, event_listeners=[listener]
)
pool = get_pool(client)
self.assertEqual(pool.opts.wait_queue_timeout, 0.01)
with pool.checkout():
with self.assertRaises(WaitQueueTimeoutError):
client.test.command("ping")
self.assertFalse(listener.events_by_type(monitoring.PoolClearedEvent))
def test_socketKeepAlive(self):
pool = get_pool(self.client)

View File

@ -425,6 +425,21 @@ class TestDatabase(IntegrationTest):
for doc in result["cursor"]["firstBatch"]:
self.assertTrue(isinstance(doc["r"], Regex))
def test_command_bulkWrite(self):
# Ensure bulk write commands can be run directly via db.command().
if client_context.version.at_least(8, 0):
self.client.admin.command(
{
"bulkWrite": 1,
"nsInfo": [{"ns": self.db.test.full_name}],
"ops": [{"insert": 0, "document": {}}],
}
)
self.db.command({"insert": "test", "documents": [{}]})
self.db.command({"update": "test", "updates": [{"q": {}, "u": {"$set": {"x": 1}}}]})
self.db.command({"delete": "test", "deletes": [{"q": {}, "limit": 1}]})
self.db.test.drop()
def test_cursor_command(self):
db = self.client.pymongo_test
db.test.drop()

View File

@ -2964,9 +2964,10 @@ class TestAutomaticDecryptionKeys(EncryptionIntegrationTest):
)
def test_03_invalid_keyid(self):
# checkAuthForCreateCollection can be removed when SERVER-102101 is fixed.
with self.assertRaisesRegex(
EncryptedCollectionError,
"create.encryptedFields.fields.keyId' is the wrong type 'bool', expected type 'binData",
"(create|checkAuthForCreateCollection).encryptedFields.fields.keyId' is the wrong type 'bool', expected type 'binData",
):
self.client_encryption.create_encrypted_collection(
database=self.db,