-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 3.6.12, 4.0.9
-
Component/s: Internal Code
-
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:
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