[DRIVERS-336] Change "no maxStalenessSeconds" value from 0 to -1 Created: 09/Nov/16  Updated: 15/Apr/19  Resolved: 08/Dec/16

Status: Closed
Project: Drivers
Component/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Rathi Gnanasekaran Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on JAVA-2383 Java driver IllegalStateException: st... Closed
depends on CSHARP-1833 Change "no maxStalenessSeconds" value... Closed
depends on CXX-1139 Change "no maxStalenessSeconds" value... Closed
depends on NODE-858 Change "no maxStalenessSeconds" value... Closed
depends on PHPC-840 Change "no maxStalenessSeconds" value... Closed
depends on RUBY-1177 Change "no maxStalenessSeconds" value... Closed
depends on PYTHON-1169 Change maxStalenessMS default to -1 (... Closed
depends on CDRIVER-1908 Change "no maxStalenessMS" value from... Closed
Related
is related to DRIVERS-335 Update Max Staleness implementation Closed
is related to DRIVERS-293 Allow users to set a limit on accepta... Closed
is related to DRIVERS-340 Make minimum value of maxStalenessSec... Closed
Driver Compliance:
Key Status/Resolution FixVersion
PYTHON-1169 Done 3.4
CDRIVER-1908 Done 1.5.0
CSHARP-1833 Duplicate 2.4
SCALA-285 Done
PHPC-840 Duplicate
RUBY-1177 Done 2.4.0
CXX-1139 Duplicate
JAVA-2383 Done 3.4.0
NODE-858 Done 2.2.12
PERL-684 Done 1.6.0

 Description   

In DRIVERS-335 we rename maxStalenessMS to maxStalenessSeconds and change the smallest value for it. In this ticket, we change the behaviors for maxStalenessSeconds=0 and maxStalenessSeconds=-1.

The spec originally specified 0 for "no max", but that value is confusing. Users will expect 0 to mean "no lag". The spec has been updated to use -1 instead (0 is now illegal).

A MongoClient with this connection string has no max staleness, the same as if "maxStalenessSeconds" were omitted from the connection string:

mongodb://host/?readPreference=secondary&maxStalenessSeconds=-1

This connection string with mode "primary" is valid and does not raise an error:

mongodb://host/?readPreference=primary&maxStalenessSeconds=-1

Same with this implicit mode "primary", this is valid too:

mongodb://host/?maxStalenessSeconds=-1

In code, -1 is an acceptable value meaning "no max staleness". E.g. in PyMongo:

MongoClient(readPreference="secondary", maxStalenessSeconds=-1)

You MAY accept null in code, too: up to you.

These are no longer valid:

mongodb://host/?readPreference=secondary&maxStalenessSeconds=0
mongodb://host/?readPreference=primary&maxStalenessSeconds=0

You can choose whether to explicitly prohibit 0 and raise an error as soon as the URI is parsed, or later when you're in server selection you could raise an error since maxStalenessSeconds=0 is too small: maxStalenessSeconds must be at least heartbeatFrequencyMS + idleWriteFrequencyMS (DRIVERS-335).



 Comments   
Comment by Rathi Gnanasekaran [ 08/Dec/16 ]

Closing ticket as all linked tickets are resolved.

Generated at Thu Feb 08 08:21:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.