Bug #62282 LOCK_thread_count is used for random functions
Submitted: 28 Aug 2011 21:52 Modified: 31 May 2012 17:31
Reporter: Domas Mituzas Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DML Severity:S5 (Performance)
Version:5.5, 5.1, ... OS:Any
Assigned to: CPU Architecture:Any

[28 Aug 2011 21:52] Domas Mituzas
Description:
functions like UUID() as well as THD::THD() initializer is calling:

inline ulong sql_rnd_with_mutex()
{
  mysql_mutex_lock(&LOCK_thread_count);
  ulong tmp=(ulong) (my_rnd(&sql_rand) * 0xffffffff); /* make all bits random */
  mysql_mutex_unlock(&LOCK_thread_count);
  return tmp;
}

How to repeat:
run MySQL

Suggested fix:
use separate mutex, don't call this function in THD initializer (slows down accepts), use lockless rand algorithm?
[31 May 2012 17:31] Paul DuBois
Noted in 5.6.6 changelog.

An inappropriate mutex was used to protect random number generation,
causing contention during connect operations.