Skip to content

Commit 2a3d4c3

Browse files
committed
Merge branch 'master' of github.com:mongodb/mongo-python-driver into PYTHON-5215
2 parents b5e8c0e + bfa01c6 commit 2a3d4c3

File tree

8 files changed

+129
-20
lines changed

8 files changed

+129
-20
lines changed

.evergreen/scripts/install-dependencies.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ if ! command -v just &>/dev/null; then
4848
_TARGET="--target x86_64-pc-windows-msvc"
4949
fi
5050
_BIN_DIR=$PYMONGO_BIN_DIR
51+
mkdir -p ${_BIN_DIR}
5152
echo "Installing just..."
5253
mkdir -p "$_BIN_DIR" 2>/dev/null || true
5354
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- $_TARGET --to "$_BIN_DIR" || {
@@ -61,6 +62,7 @@ fi
6162
# Ensure uv is installed.
6263
if ! command -v uv &>/dev/null; then
6364
_BIN_DIR=$PYMONGO_BIN_DIR
65+
mkdir -p ${_BIN_DIR}
6466
echo "Installing uv..."
6567
# On most systems we can install directly.
6668
curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR="$_BIN_DIR" INSTALLER_NO_MODIFY_PATH=1 sh || {

.evergreen/scripts/kms_tester.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _setup_azure_vm(base_env: dict[str, str]) -> None:
3030
env["AZUREKMS_CMD"] = "tar xf mongo-python-driver.tgz"
3131
run_command(f"{azure_dir}/run-command.sh", env=env)
3232

33-
env["AZUREKMS_CMD"] = "bash .evergreen/just.sh setup-tests kms azure-remote"
33+
env["AZUREKMS_CMD"] = "NO_EXT=1 bash .evergreen/just.sh setup-tests kms azure-remote"
3434
run_command(f"{azure_dir}/run-command.sh", env=env)
3535
LOGGER.info("Setting up Azure VM... done.")
3636

@@ -47,7 +47,7 @@ def _setup_gcp_vm(base_env: dict[str, str]) -> None:
4747
env["GCPKMS_CMD"] = "tar xf mongo-python-driver.tgz"
4848
run_command(f"{gcp_dir}/run-command.sh", env=env)
4949

50-
env["GCPKMS_CMD"] = "bash ./.evergreen/just.sh setup-tests kms gcp-remote"
50+
env["GCPKMS_CMD"] = "NO_EXT=1 bash ./.evergreen/just.sh setup-tests kms gcp-remote"
5151
run_command(f"{gcp_dir}/run-command.sh", env=env)
5252
LOGGER.info("Setting up GCP VM...")
5353

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
diff --git a/test/connection_logging/connection-logging.json b/test/connection_logging/connection-logging.json
2+
index d40cfbb7e..5799e834d 100644
3+
--- a/test/connection_logging/connection-logging.json
4+
+++ b/test/connection_logging/connection-logging.json
5+
@@ -272,7 +272,13 @@
6+
"level": "debug",
7+
"component": "connection",
8+
"data": {
9+
- "message": "Connection pool closed",
10+
+ "message": "Connection closed",
11+
+ "driverConnectionId": {
12+
+ "$$type": [
13+
+ "int",
14+
+ "long"
15+
+ ]
16+
+ },
17+
"serverHost": {
18+
"$$type": "string"
19+
},
20+
@@ -281,20 +287,15 @@
21+
"int",
22+
"long"
23+
]
24+
- }
25+
+ },
26+
+ "reason": "Connection pool was closed"
27+
}
28+
},
29+
{
30+
"level": "debug",
31+
"component": "connection",
32+
"data": {
33+
- "message": "Connection closed",
34+
- "driverConnectionId": {
35+
- "$$type": [
36+
- "int",
37+
- "long"
38+
- ]
39+
- },
40+
+ "message": "Connection pool closed",
41+
"serverHost": {
42+
"$$type": "string"
43+
},
44+
@@ -303,8 +304,7 @@
45+
"int",
46+
"long"
47+
]
48+
- },
49+
- "reason": "Connection pool was closed"
50+
+ }
51+
}
52+
}
53+
]
54+
@@ -446,22 +446,6 @@
55+
}
56+
}
57+
},
58+
- {
59+
- "level": "debug",
60+
- "component": "connection",
61+
- "data": {
62+
- "message": "Connection pool cleared",
63+
- "serverHost": {
64+
- "$$type": "string"
65+
- },
66+
- "serverPort": {
67+
- "$$type": [
68+
- "int",
69+
- "long"
70+
- ]
71+
- }
72+
- }
73+
- },
74+
{
75+
"level": "debug",
76+
"component": "connection",
77+
@@ -514,6 +498,22 @@
78+
]
79+
}
80+
}
81+
+ },
82+
+ {
83+
+ "level": "debug",
84+
+ "component": "connection",
85+
+ "data": {
86+
+ "message": "Connection pool cleared",
87+
+ "serverHost": {
88+
+ "$$type": "string"
89+
+ },
90+
+ "serverPort": {
91+
+ "$$type": [
92+
+ "int",
93+
+ "long"
94+
+ ]
95+
+ }
96+
+ }
97+
}
98+
]
99+
}

pymongo/asynchronous/server.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
_SDAMStatusMessage,
3939
)
4040
from pymongo.message import _convert_exception, _GetMore, _OpMsg, _Query
41+
from pymongo.pool_shared import _get_timeout_details, format_timeout_details
4142
from pymongo.response import PinnedResponse, Response
4243

4344
if TYPE_CHECKING:
@@ -224,6 +225,10 @@ async def run_operation(
224225
if use_cmd:
225226
first = docs[0]
226227
await operation.client._process_response(first, operation.session) # type: ignore[misc, arg-type]
228+
# Append timeout details to MaxTimeMSExpired responses.
229+
if first.get("code") == 50:
230+
timeout_details = _get_timeout_details(conn.opts) # type:ignore[has-type]
231+
first["errmsg"] += format_timeout_details(timeout_details) # type:ignore[index]
227232
_check_command_response(first, conn.max_wire_version)
228233
except Exception as exc:
229234
duration = datetime.now() - start

pymongo/synchronous/server.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
_SDAMStatusMessage,
3838
)
3939
from pymongo.message import _convert_exception, _GetMore, _OpMsg, _Query
40+
from pymongo.pool_shared import _get_timeout_details, format_timeout_details
4041
from pymongo.response import PinnedResponse, Response
4142
from pymongo.synchronous.helpers import _handle_reauth
4243

@@ -224,6 +225,10 @@ def run_operation(
224225
if use_cmd:
225226
first = docs[0]
226227
operation.client._process_response(first, operation.session) # type: ignore[misc, arg-type]
228+
# Append timeout details to MaxTimeMSExpired responses.
229+
if first.get("code") == 50:
230+
timeout_details = _get_timeout_details(conn.opts) # type:ignore[has-type]
231+
first["errmsg"] += format_timeout_details(timeout_details) # type:ignore[index]
227232
_check_command_response(first, conn.max_wire_version)
228233
except Exception as exc:
229234
duration = datetime.now() - start

test/asynchronous/test_pooling.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,6 @@ async def find_one():
429429
# maxConnecting = unbounded: 30+ connections in ~0.140+ seconds
430430
print(len(pool.conns))
431431

432-
@flaky(reason="PYTHON-5492")
433432
@async_client_context.require_failCommand_appName
434433
async def test_csot_timeout_message(self):
435434
client = await self.async_rs_or_single_client(appName="connectionTimeoutApp")

test/connection_logging/connection-logging.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -446,22 +446,6 @@
446446
}
447447
}
448448
},
449-
{
450-
"level": "debug",
451-
"component": "connection",
452-
"data": {
453-
"message": "Connection pool cleared",
454-
"serverHost": {
455-
"$$type": "string"
456-
},
457-
"serverPort": {
458-
"$$type": [
459-
"int",
460-
"long"
461-
]
462-
}
463-
}
464-
},
465449
{
466450
"level": "debug",
467451
"component": "connection",
@@ -514,6 +498,22 @@
514498
]
515499
}
516500
}
501+
},
502+
{
503+
"level": "debug",
504+
"component": "connection",
505+
"data": {
506+
"message": "Connection pool cleared",
507+
"serverHost": {
508+
"$$type": "string"
509+
},
510+
"serverPort": {
511+
"$$type": [
512+
"int",
513+
"long"
514+
]
515+
}
516+
}
517517
}
518518
]
519519
}

test/test_pooling.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,6 @@ def find_one():
429429
# maxConnecting = unbounded: 30+ connections in ~0.140+ seconds
430430
print(len(pool.conns))
431431

432-
@flaky(reason="PYTHON-5492")
433432
@client_context.require_failCommand_appName
434433
def test_csot_timeout_message(self):
435434
client = self.rs_or_single_client(appName="connectionTimeoutApp")

0 commit comments

Comments
 (0)