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

Ensure ReplicaSetMonitor initializes its random state with truly random data

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 3.6.12, 4.0.9
    • 3.6.14, 4.0.13
    • Internal Code
    • Fully Compatible
    • ALL
    • v4.0, v3.6
    • 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

            ben.caimano@mongodb.com Benjamin Caimano (Inactive)
            jason.carey@mongodb.com Jason Carey
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: