Commit 58de1660 authored by Jon Olav Hauglid's avatar Jon Olav Hauglid

Bug#14621627 THREAD CACHE IS UNFAIR

When a client connects to a MySQL server, first a THD object is created.
If there are any idle server threads waiting, the THD object is then added
to a list and a server thread is woken up. This thread then retrieves the 
THD object from the list and starts executing.

The problem was that this list of THD objects waiting for a server thread,
was not working in a FIFO fashion, but rather LIFO. This is unfair, as it means
that the last THD added (=last client connected) will be assigned a  server 
thread first.

Note however that for this to be a problem, several clients must be able
to connect and have THD objects constructed before any server threads
manages to be woken up. This is not a very likely scenario.

This patch fixes the problem by changing the THD list to work FIFO
rather than LIFO.

This is the 5.1/5.5 version of the patch.
parent 815aad69
...@@ -4808,7 +4808,7 @@ void create_thread_to_handle_connection(THD *thd) ...@@ -4808,7 +4808,7 @@ void create_thread_to_handle_connection(THD *thd)
if (cached_thread_count > wake_thread) if (cached_thread_count > wake_thread)
{ {
/* Get thread from cache */ /* Get thread from cache */
thread_cache.append(thd); thread_cache.push_back(thd);
wake_thread++; wake_thread++;
pthread_cond_signal(&COND_thread_cache); pthread_cond_signal(&COND_thread_cache);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment