Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-41248

Ensure ReplicaSetMonitor initializes its random state with truly random data

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.6.12, 4.0.9
    • Fix Version/s: 3.6.14, 4.0.13
    • Component/s: Internal Code
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v4.0, v3.6
    • Sprint:
      Service Arch 2019-07-15, Service Arch 2019-08-12, Service Arch 2019-08-26

      Description

      The replica set monitor in older versions of the server initializes it's random state via:

      replica_set_monitor.cpp:1010

      SetState::SetState(...) :
          ...
          rand(int64_t(time(0))),
          ...
      

      which has the unfortunate side effect of being strongly synchronized with the system clock. This can cause non-random patterns of access across a mongos / series of mongos' in cases where all of the nodes are restarted at the same time and work is distributed evenly across the various mongos'.

      Switching to use a real source of randomness for seeding the prngs in each set state should improve the real randomness of later server selection


      Note: It appears this was fixed in 4.2 as part of unrelated code changes

        Attachments

          Activity

            People

            Assignee:
            ben.caimano Benjamin Caimano
            Reporter:
            jason.carey Jason Carey
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: