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

Ensure ReplicaSetMonitor initializes its random state with truly random data

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.6.14, 4.0.13
    • Affects Version/s: 3.6.12, 4.0.9
    • Component/s: Internal Code
    • Labels:
    • Fully Compatible
    • ALL
    • v4.0, v3.6
    • Service Arch 2019-07-15, Service Arch 2019-08-12, Service Arch 2019-08-26

      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

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

              Created:
              Updated:
              Resolved: