Bug #60197 | random used in a multithreaded context | ||
---|---|---|---|
Submitted: | 22 Feb 2011 7:48 | Modified: | 14 Apr 2011 10:37 |
Reporter: | Guoliang Jin | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Command-line Clients | Severity: | S5 (Performance) |
Version: | 5.1.55 | OS: | Windows |
Assigned to: | CPU Architecture: | Any |
[22 Feb 2011 7:48]
Guoliang Jin
[27 Feb 2011 13:25]
MySQL Verification Team
I verify the fact that random() is used, and what the manpage says: http://www.kernel.org/doc/man-pages/online/pages/man3/random.3.html\ However, mysqlslap doesn't use a constant seed to generate repeatable random numbers in multiple threads. It just needs random numbers without being repeatable later. /* Seed the random number generator if we will be using it. */ if (auto_generate_sql) srandom((uint)time(NULL)); So if the only problem is not having repeatable sequences, is this really a bug at all?
[27 Feb 2011 20:31]
Guoliang Jin
According to http://evanjones.ca/random-thread-safe.html, the reason that random() should not be used in multi-thread context on Linux is that rand() and random() acquire a mutex to ensure thread-safe on Linux, and this could over-synchronize the problem and may lead to performance issue, thus random_r() should be used instead. Bug 38941 is a previous case related to random().