Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5ad9007
DRIVERS-3218 Avoid clearing the connection pool when the server conne…
blink1073 Nov 11, 2025
5536501
capitalization
blink1073 Nov 11, 2025
199c4d7
address tech review
blink1073 Nov 11, 2025
aa08fe9
bump schema versions
blink1073 Nov 12, 2025
7d32469
bump schema versions
blink1073 Nov 12, 2025
4d318fa
update tests
blink1073 Nov 12, 2025
2c87677
address review
blink1073 Nov 12, 2025
f46d39c
Add connection pool prose tests
blink1073 Nov 14, 2025
a14cacc
Add test for backpressure error label on command error
blink1073 Nov 17, 2025
fdcacbd
update sdam test
blink1073 Nov 17, 2025
53a7fdf
udpate schema version
blink1073 Nov 17, 2025
2a287dc
cleanup
blink1073 Nov 17, 2025
c8d1a33
fix test
blink1073 Nov 17, 2025
f4106e8
formatting
blink1073 Nov 17, 2025
bdde73f
replace tests
blink1073 Nov 17, 2025
99948d7
remove superfluous test and clarify spec
blink1073 Nov 19, 2025
3779d26
update language about distinguishing errors
blink1073 Nov 19, 2025
94a082e
Update source/server-discovery-and-monitoring/server-discovery-and-mo…
blink1073 Nov 20, 2025
659133f
Address review
blink1073 Nov 20, 2025
9dedf63
run mdformat
blink1073 Nov 20, 2025
b70d360
clean up prose test
blink1073 Nov 20, 2025
00e54b0
update the min pool size test
blink1073 Nov 20, 2025
6bd9f70
bump schema versions
blink1073 Nov 20, 2025
9b9c4af
address review
blink1073 Nov 21, 2025
da3885a
add changelog dates
blink1073 Nov 21, 2025
7464e61
fix Single-threaded monitor section
blink1073 Nov 21, 2025
eeac077
address review
blink1073 Nov 25, 2025
fa9633b
Merge branch 'master' of github.com:mongodb/specifications into DRIVE…
blink1073 Nov 25, 2025
7205ef0
lint
blink1073 Nov 25, 2025
21eff0f
Update source/server-discovery-and-monitoring/server-monitoring.md
blink1073 Nov 25, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ Endpoint. The pool has the following properties:
- **Rate-limited:** A Pool MUST limit the number of [Connections](#connection) being
[established](#establishing-a-connection-internal-implementation) concurrently via the **maxConnecting**
[pool option](#connection-pool-options).
- **Backpressure-enabled** - The pool MUST add the error labels `SystemOverloadedError` and `RetryableError` to network
errors or network timeouts it encounters during the connection establishment or the `hello` message. These labels
are used by the
[SDAM error handling](../server-discovery-and-monitoring/server-discovery-and-monitoring.md#error-handling-pseudocode)
to avoid clearing the pool. The pool MUST NOT add the backpressure error labels during an authentication step
after the `hello` message.

```typescript
interface ConnectionPool {
Expand Down Expand Up @@ -1375,6 +1381,8 @@ to close and remove from its pool a [Connection](#connection) which has unread e

## Changelog

- 2025-XX-YY: Add handling of backpressure error labels.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changelog dates?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


- 2025-01-22: Clarify durationMS in logs may be Int32/Int64/Double.

- 2024-11-27: Relaxed the WaitQueue fairness requirement.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ failPoint:
mode: { times: 50 }
data:
failCommands: ["isMaster","hello"]
closeConnection: true
errorCode: 91
appName: "poolCreateMinSizeErrorTest"
poolOptions:
minPoolSize: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,18 +434,18 @@ correspond to [replica set member states](https://www.mongodb.com/docs/manual/re
some replica set member states like STARTUP and RECOVERING are identical from the client's perspective, so they are
merged into "RSOther". Additionally, states like Standalone and Mongos are not replica set member states at all.

| State | Symptoms |
| --------------- | ------------------------------------------------------------------------------------------------------------------------- |
| Unknown | Initial, or after a network error or failed hello or legacy hello call, or "ok: 1" not in hello or legacy hello response. |
| Standalone | No "msg: isdbgrid", no setName, and no "isreplicaset: true". |
| Mongos | "msg: isdbgrid". |
| PossiblePrimary | Not yet checked, but another member thinks it is the primary. |
| RSPrimary | "isWritablePrimary: true" or "ismaster: true", "setName" in response. |
| RSSecondary | "secondary: true", "setName" in response. |
| RSArbiter | "arbiterOnly: true", "setName" in response. |
| RSOther | "setName" in response, "hidden: true" or not primary, secondary, nor arbiter. |
| RSGhost | "isreplicaset: true" in response. |
| LoadBalanced | "loadBalanced=true" in URI. |
| State | Symptoms |
| --------------- | -------------------------------------------------------------------------------------------------------- |
| Unknown | Initial, or after a failed hello or legacy hello call, or "ok: 1" not in hello or legacy hello response. |
| Standalone | No "msg: isdbgrid", no setName, and no "isreplicaset: true". |
| Mongos | "msg: isdbgrid". |
| PossiblePrimary | Not yet checked, but another member thinks it is the primary. |
| RSPrimary | "isWritablePrimary: true" or "ismaster: true", "setName" in response. |
| RSSecondary | "secondary: true", "setName" in response. |
| RSArbiter | "arbiterOnly: true", "setName" in response. |
| RSOther | "setName" in response, "hidden: true" or not primary, secondary, nor arbiter. |
| RSGhost | "isreplicaset: true" in response. |
| LoadBalanced | "loadBalanced=true" in URI. |

A server can transition from any state to any other. For example, an administrator could shut down a secondary and bring
up a mongos in its place.
Expand Down Expand Up @@ -1056,6 +1056,9 @@ def handleError(error):
if isNotWritablePrimary(error):
check failing server
elif isNetworkError(error) or (not error.completedHandshake and (isNetworkTimeout(error) or isAuthError(error))):
# Ignore errors that have a backpressure error label applied.
if error.hasLabel("SystemOverloadedError"):
continue
if type != LoadBalanced
# Mark the server Unknown
unknown = new ServerDescription(type=Unknown, error=error)
Expand Down Expand Up @@ -1139,16 +1142,20 @@ errors, network timeout errors, state change errors, and authentication errors.

##### Network error when reading or writing

To describe how the client responds to network errors during application operations, we distinguish two phases of
To describe how the client responds to network errors during application operations, we distinguish three phases of
connecting to a server and using it for application operations:

- *Before the handshake completes*: the client establishes a new connection to the server and completes an initial
handshake by calling "hello" or legacy hello and reading the response, and optionally completing authentication
- *Connection establishment and hello*: the client establishes a new connection to the server and completes an initial
handshake by calling "hello" or legacy hello and reading the response
- *Authentication step*: the client optionally completes an authentication step
- *After the handshake completes*: the client uses the established connection for application operations

If there is a network error or timeout on the connection before the handshake completes, the client MUST replace the
server's description with a default ServerDescription of type Unknown when the TopologyType is not LoadBalanced, and
fill the ServerDescription's error field with useful information.
If there is a network error or timeout on the connection establishment or the hello, the client MUST NOT change the
server's description.

If there is an network error or timeout during the authentication step,, the client MUST replace the server's
description with a default ServerDescription of type Unknown when the TopologyType is not LoadBalanced, and fill the
ServerDescription's error field with useful information.

If there is a network error or timeout on the connection before the handshake completes, and the TopologyType is
LoadBalanced, the client MUST keep the ServerDescription as LoadBalancer.
Expand Down Expand Up @@ -1255,9 +1262,10 @@ and [other transient errors](#other-transient-errors) and

##### Authentication and Handshake errors

If the driver encounters errors when establishing application connections (this includes the initial handshake and
authentication), the driver MUST mark the server Unknown and clear the server's connection pool if the TopologyType is
not LoadBalanced. (See [Why mark a server Unknown after an auth error?](#why-mark-a-server-unknown-after-an-auth-error))
If the driver encounters errors that do not have the backpressure error label (`SystemOverloadedError`) applied when
establishing application connections (this includes the initial handshake and authentication), the driver MUST mark the
server Unknown and clear the server's connection pool if the TopologyType is not LoadBalanced. (See
[Why mark a server Unknown after an auth error?](#why-mark-a-server-unknown-after-an-auth-error))

### Monitoring SDAM events

Expand Down Expand Up @@ -2027,6 +2035,8 @@ oversaw the specification process.
- 2025-01-22: Add error messages when a new primary is elected or a primary with a stale electionId or setVersion is
discovered.

- 2025-XX-YY: Add handling of backpressure error labels.

______________________________________________________________________

[^1]: "localThresholdMS" was called "secondaryAcceptableLatencyMS" in the Read Preferences Spec, before it was superseded
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading