@@ -434,18 +434,18 @@ correspond to [replica set member states](https://www.mongodb.com/docs/manual/re
434434some replica set member states like STARTUP and RECOVERING are identical from the client's perspective, so they are
435435merged into "RSOther". Additionally, states like Standalone and Mongos are not replica set member states at all.
436436
437- | State | Symptoms |
438- | --------------- | ------------------------------------------------------------------------------------------------------------------------- |
439- | Unknown | Initial, or after a network error or failed hello or legacy hello call, or "ok: 1" not in hello or legacy hello response. |
440- | Standalone | No "msg: isdbgrid", no setName, and no "isreplicaset: true". |
441- | Mongos | "msg: isdbgrid". |
442- | PossiblePrimary | Not yet checked, but another member thinks it is the primary. |
443- | RSPrimary | "isWritablePrimary: true" or "ismaster: true", "setName" in response. |
444- | RSSecondary | "secondary: true", "setName" in response. |
445- | RSArbiter | "arbiterOnly: true", "setName" in response. |
446- | RSOther | "setName" in response, "hidden: true" or not primary, secondary, nor arbiter. |
447- | RSGhost | "isreplicaset: true" in response. |
448- | LoadBalanced | "loadBalanced=true" in URI. |
437+ | State | Symptoms |
438+ | --------------- | -------------------------------------------------------------------------------------------------------- |
439+ | Unknown | Initial, or after a failed hello or legacy hello call, or "ok: 1" not in hello or legacy hello response. |
440+ | Standalone | No "msg: isdbgrid", no setName, and no "isreplicaset: true". |
441+ | Mongos | "msg: isdbgrid". |
442+ | PossiblePrimary | Not yet checked, but another member thinks it is the primary. |
443+ | RSPrimary | "isWritablePrimary: true" or "ismaster: true", "setName" in response. |
444+ | RSSecondary | "secondary: true", "setName" in response. |
445+ | RSArbiter | "arbiterOnly: true", "setName" in response. |
446+ | RSOther | "setName" in response, "hidden: true" or not primary, secondary, nor arbiter. |
447+ | RSGhost | "isreplicaset: true" in response. |
448+ | LoadBalanced | "loadBalanced=true" in URI. |
449449
450450A server can transition from any state to any other. For example, an administrator could shut down a secondary and bring
451451up a mongos in its place.
@@ -1055,7 +1055,10 @@ def handleError(error):
10551055 # next full scan.
10561056 if isNotWritablePrimary(error):
10571057 check failing server
1058- elif isNetworkError(error) or (not error.completedHandshake and (isNetworkTimeout(error) or isAuthError(error))):
1058+ elif isNetworkError(error) or (not error.completedHandshake):
1059+ # Ignore errors that have a backpressure error label applied.
1060+ if error.hasLabel(" SystemOverloadedError" ):
1061+ continue
10591062 if type != LoadBalanced
10601063 # Mark the server Unknown
10611064 unknown = new ServerDescription(type = Unknown, error = error)
@@ -1139,16 +1142,20 @@ errors, network timeout errors, state change errors, and authentication errors.
11391142
11401143##### Network error when reading or writing
11411144
1142- To describe how the client responds to network errors during application operations, we distinguish two phases of
1145+ To describe how the client responds to network errors during application operations, we distinguish three phases of
11431146connecting to a server and using it for application operations:
11441147
1145- - * Before the handshake completes* : the client establishes a new connection to the server and completes an initial
1146- handshake by calling "hello" or legacy hello and reading the response, and optionally completing authentication
1148+ - * Connection establishment and hello* : the client establishes a new connection to the server and completes an initial
1149+ handshake by calling "hello" or legacy hello and reading the response
1150+ - * Authentication step* : the client optionally completes an authentication step
11471151- * After the handshake completes* : the client uses the established connection for application operations
11481152
1149- If there is a network error or timeout on the connection before the handshake completes, the client MUST replace the
1150- server's description with a default ServerDescription of type Unknown when the TopologyType is not LoadBalanced, and
1151- fill the ServerDescription's error field with useful information.
1153+ If there is a network error or timeout on the connection establishment or the hello, the client MUST NOT change the
1154+ server's description.
1155+
1156+ If there is an network error or timeout during the authentication step, the client MUST replace the server's description
1157+ with a default ServerDescription of type Unknown when the TopologyType is not LoadBalanced, and fill the
1158+ ServerDescription's error field with useful information.
11521159
11531160If there is a network error or timeout on the connection before the handshake completes, and the TopologyType is
11541161LoadBalanced, the client MUST keep the ServerDescription as LoadBalancer.
@@ -1253,11 +1260,12 @@ if and only if the error is "node is shutting down" or the error originated from
12531260and [ other transient errors] ( #other-transient-errors ) and
12541261[ Why close connections when a node is shutting down?] ( #why-close-connections-when-a-node-is-shutting-down ) .)
12551262
1256- ##### Authentication and Handshake errors
1263+ ##### MongoDB Handshake errors
12571264
1258- If the driver encounters errors when establishing application connections (this includes the initial handshake and
1259- authentication), the driver MUST mark the server Unknown and clear the server's connection pool if the TopologyType is
1260- not LoadBalanced. (See [ Why mark a server Unknown after an auth error?] ( #why-mark-a-server-unknown-after-an-auth-error ) )
1265+ If the driver encounters errors that do not have the backpressure error label (` SystemOverloadedError ` ) applied when
1266+ establishing application connections (this includes the initial handshake and authentication), the driver MUST mark the
1267+ server Unknown and clear the server's connection pool if the TopologyType is not LoadBalanced. (See
1268+ [ Why mark a server Unknown after an auth error?] ( #why-mark-a-server-unknown-after-an-auth-error ) )
12611269
12621270### Monitoring SDAM events
12631271
@@ -2027,6 +2035,8 @@ oversaw the specification process.
20272035- 2025-01-22: Add error messages when a new primary is elected or a primary with a stale electionId or setVersion is
20282036 discovered.
20292037
2038+ - 2025-11-21: Add handling of backpressure error labels.
2039+
20302040______________________________________________________________________
20312041
20322042[ ^ 1 ] : "localThresholdMS" was called "secondaryAcceptableLatencyMS" in the Read Preferences Spec, before it was superseded
0 commit comments