| Bug #24727 | LOCK_thread_count acquired for too much time | ||
|---|---|---|---|
| Submitted: | 30 Nov 2006 16:55 | Modified: | 30 Nov 2006 19:30 |
| Reporter: | Andrey Hristov | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server | Severity: | S5 (Performance) |
| Version: | 4.1, 5.0, 5.1 | OS: | Any (All) |
| Assigned to: | CPU Architecture: | Any | |
[30 Nov 2006 19:30]
Andrey Hristov
thd->query assignment should be protected for mysql_list_processes()

Description: Reading sql_parse.cc, dispatch_command(), COM_QUERY: the mutex LOCK_thread_count is hold for more than usual. Only thd->query_id= query_id++; should be protected by the lock. Even more, it should not be required this code to hold a lock. Better it should be moved to the in 5.0 existing inline function next_query_id(). This function should not use pthread_mutex_lock()/unlock() but thread_safe_increment() macro. How to repeat: sql_parse.cc: VOID(pthread_mutex_lock(&LOCK_thread_count)); thd->query_length= length; thd->query= packet; thd->query_id= query_id++; thd->set_time(); /* Reset the query start time. */ /* TODO: set thd->lex->sql_command to SQLCOM_END here */ VOID(pthread_mutex_unlock(&LOCK_thread_count));