Skip to content

Commit 91b963d

Browse files
authored
DRIVERS-1912 Clarify maxWireVersion check for maxStalenessSeconds (#1064)
1 parent ff5d91f commit 91b963d

File tree

4 files changed

+104
-9
lines changed

4 files changed

+104
-9
lines changed

source/max-staleness/max-staleness.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Max Staleness
1010
:Status: Accepted
1111
:Type: Standards
1212
:Last Modified: April 6, 2021
13-
:Version: 1.4
13+
:Version: 1.4.1
1414

1515
.. contents::
1616

@@ -484,8 +484,12 @@ Therefore, this spec *also* requires that maxStalenessSeconds is at least 90:
484484
All servers must have wire version 5 to support maxStalenessSeconds
485485
-------------------------------------------------------------------
486486

487-
Clients are required to throw an error if maxStalenessSeconds is set,
488-
and any server in the topology has maxWireVersion less than 5.
487+
Clients with minWireVersion < 5 MUST throw an error if maxStalenessSeconds is set,
488+
and any available server in the topology has maxWireVersion less than 5.
489+
490+
An available server is defined in the `Server Selection
491+
<../server-selection/server-selection.rst#terms>`_
492+
specification.
489493

490494
Servers began reporting lastWriteDate in wire protocol version 5,
491495
and clients require some or all servers' lastWriteDate in order to
@@ -593,6 +597,7 @@ Changes
593597
=======
594598

595599
2021-09-08: Updated tests to support driver removal of support for server versions older than 3.6.
600+
2021-09-03: Clarify that wire version check only applies to available servers.
596601
2021-04-06: Updated to use hello command.
597602
2016-09-29: Specify "no max staleness" in the URI with "maxStalenessMS=-1"
598603
instead of "maxStalenessMS=0".
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"topology_description": {
3+
"type": "ReplicaSetNoPrimary",
4+
"servers": [
5+
{
6+
"address": "a:27017",
7+
"type": "PossiblePrimary",
8+
"avg_rtt_ms": 5,
9+
"maxWireVersion": 0
10+
},
11+
{
12+
"address": "b:27017",
13+
"type": "Unknown",
14+
"avg_rtt_ms": 5,
15+
"maxWireVersion": 0
16+
},
17+
{
18+
"address": "c:27017",
19+
"type": "RSSecondary",
20+
"maxWireVersion": 6,
21+
"avg_rtt_ms": 5,
22+
"lastWrite": {
23+
"lastWriteDate": {
24+
"$numberLong": "1"
25+
}
26+
}
27+
}
28+
]
29+
},
30+
"read_preference": {
31+
"mode": "Nearest",
32+
"maxStalenessSeconds": 120
33+
},
34+
"suitable_servers": [
35+
{
36+
"address": "c:27017",
37+
"type": "RSSecondary",
38+
"maxWireVersion": 6,
39+
"avg_rtt_ms": 5,
40+
"lastWrite": {
41+
"lastWriteDate": {
42+
"$numberLong": "1"
43+
}
44+
}
45+
}
46+
],
47+
"in_latency_window": [
48+
{
49+
"address": "c:27017",
50+
"type": "RSSecondary",
51+
"maxWireVersion": 6,
52+
"avg_rtt_ms": 5,
53+
"lastWrite": {
54+
"lastWriteDate": {
55+
"$numberLong": "1"
56+
}
57+
}
58+
}
59+
]
60+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Clients ignore Unknown/PossiblePrimary servers even when read preference has maxStalenessSeconds
2+
topology_description:
3+
type: ReplicaSetNoPrimary
4+
servers:
5+
- &1
6+
address: a:27017
7+
type: PossiblePrimary
8+
avg_rtt_ms: 5
9+
maxWireVersion: 0
10+
- &2
11+
address: b:27017
12+
type: Unknown
13+
avg_rtt_ms: 5
14+
maxWireVersion: 0
15+
- &3
16+
address: c:27017
17+
type: RSSecondary
18+
maxWireVersion: 6
19+
avg_rtt_ms: 5
20+
lastWrite: {lastWriteDate: {$numberLong: "1"}}
21+
read_preference:
22+
mode: Nearest
23+
maxStalenessSeconds: 120
24+
suitable_servers:
25+
- *3
26+
in_latency_window:
27+
- *3
28+

source/server-selection/server-selection.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Server Selection
1010
:Status: Accepted
1111
:Type: Standards
1212
:Last Modified: 2021-05-13
13-
:Version: 1.13.2
13+
:Version: 1.13.3
1414

1515
.. contents::
1616

@@ -456,9 +456,9 @@ mongos MUST reject a read with ``maxStalenessSeconds`` that is not a positive in
456456
mongos MUST reject a read if ``maxStalenessSeconds`` is less than smallestMaxStalenessSeconds,
457457
with error code 160 (SERVER-24421).
458458

459-
During server selection,
460-
drivers (but not mongos) MUST raise an error if ``maxStalenessSeconds`` is a positive number,
461-
and any server's ``maxWireVersion`` is less than 5. [#]_
459+
During server selection, drivers (but not mongos) with ``minWireVersion`` < 5
460+
MUST raise an error if ``maxStalenessSeconds`` is a positive number, and any
461+
available server's ``maxWireVersion`` is less than 5. [#]_
462462

463463
After filtering servers according to ``mode``, and before filtering with ``tag_sets``,
464464
eligibility MUST be determined from ``maxStalenessSeconds`` as follows:
@@ -1232,7 +1232,7 @@ selection`_::
12321232
throw invalid wire protocol range error with details
12331233

12341234
if maxStalenessSeconds is set:
1235-
if any server's maxWireVersion < 5:
1235+
if client minWireVersion < 5 and any available server's maxWireVersion < 5:
12361236
client.lock.release()
12371237
throw error
12381238

@@ -1317,7 +1317,7 @@ The following is pseudocode for `single-threaded server selection`_::
13171317
throw invalid wire version range error with details
13181318

13191319
if maxStalenessSeconds is set:
1320-
if any server's maxWireVersion < 5:
1320+
if client minWireVersion < 5 and any available server's maxWireVersion < 5:
13211321
throw error
13221322

13231323
if topologyDescription.type in (ReplicaSetWithPrimary, ReplicaSetNoPrimary):
@@ -1789,6 +1789,8 @@ References
17891789
Changes
17901790
=======
17911791

1792+
2021-09-03: Clarify that wire version check only applies to available servers.
1793+
17921794
2015-06-26: Updated single-threaded selection logic with "stale" and serverSelectionTryOnce.
17931795

17941796
2015-08-10: Updated single-threaded selection logic to ensure a scan always

0 commit comments

Comments
 (0)