Uploaded image for project: 'Drivers'
  1. Drivers
  2. DRIVERS-336

Change "no maxStalenessSeconds" value from 0 to -1

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Component/s: None
    • None

      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).

            Assignee:
            Unassigned Unassigned
            Reporter:
            rathi.gnanasekaran Rathi Gnanasekaran
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: