Bug #27062 | Creation of temp tables (memory/heap) sets a global mutex | ||
---|---|---|---|
Submitted: | 13 Mar 2007 3:19 | Modified: | 7 Aug 2007 19:51 |
Reporter: | Arjen Lentz | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server | Severity: | S5 (Performance) |
Version: | 5.1, 5.0 | OS: | Any (any) |
Assigned to: | Michael Widenius | CPU Architecture: | Any |
Tags: | bfsm_2007_07_19, heap, Memory, mutex, temp, tmp |
[13 Mar 2007 3:19]
Arjen Lentz
[13 Mar 2007 3:26]
Arjen Lentz
See also http://bugs.mysql.com/27063 (glibc malloc threading/scaling problems).
[13 Mar 2007 8:09]
Valeriy Kravchuk
Thank you for a problem report. Verified with code review also on 5.1-BK: int heap_create(const char *name, uint keys, HP_KEYDEF *keydef, uint reclength, ulong max_records, ulong min_records, HP_CREATE_INFO *create_info) { uint i, j, key_segs, max_length, length; HP_SHARE *share; HA_KEYSEG *keyseg; DBUG_ENTER("heap_create"); pthread_mutex_lock(&THR_LOCK_heap); ... HP_INFO *heap_open(const char *name, int mode) { HP_INFO *info; HP_SHARE *share; DBUG_ENTER("heap_open"); pthread_mutex_lock(&THR_LOCK_heap); ... int heap_close(HP_INFO *info) { int tmp; DBUG_ENTER("heap_close"); pthread_mutex_lock(&THR_LOCK_heap); tmp= hp_close(info); pthread_mutex_unlock(&THR_LOCK_heap); DBUG_RETURN(tmp); } So, same global mutext is used.
[7 Jul 2007 23:10]
Jeffrey Pugh
From Serg: > According to the following bench the problem was found in the glic > > malloc function http://ozlabs.org/~anton/linux/sysbench/ 1. "It turns out MySQL has a global mutex (THR_LOCK_heap) protecting the code in heap/*." - Arjen has already reported it as a bug: http://bugs.mysql.com/bug.php?id=27062 2. "The glibc malloc library is known to have issues with threading. ... Google have written an alternate malloc library that is known to perform better with threads." - it's WL#1289 (and WL#3661, BUG#25244, BUG#27063)
[8 Jul 2007 0:18]
Arjen Lentz
Jeffrey- unless the replacement malloc library can be included in the near future, I think another solution is needed. This is not just for people explicitly using MEMORY tables, it's the server *internally* using temporary MEMORY tables during execution of a query. This affects your major scale-out customers. If more than one connection at a time has to create a temporary table (not unlikely on a busy site), you don't want one blocking all the others. That's just not good for performance. I'm sure adjustments can be made in the code that would at least minimize the mutex duration.
[7 Aug 2007 17:29]
Michael Widenius
Fixed in 5.source tree. Will be in 5.1.21
[7 Aug 2007 19:51]
Paul DuBois
Noted in 5.1.21 changelog. The server acquired a global mutex for temporary tables, although such tables are thread-specific. This affected performance by blocking other threads.