Kristofer Pettersson
b22d02ad42
Bug#43758 Query cache can lock up threads in 'freeing items' state
...
Early patch submitted for discussion.
It is possible for more than one thread to enter the condition
in query_cache_insert(), but the condition predicate is to
signal one thread each time the cache status changes between
the following states: {NO_FLUSH_IN_PROGRESS,FLUSH_IN_PROGRESS,
TABLE_FLUSH_IN_PROGRESS}
Consider three threads THD1, THD2, THD3
THD2: select ... => Got a writer in ::store_query
THD3: select ... => Got a writer in ::store_query
THD1: flush tables => qc status= FLUSH_IN_PROGRESS;
new writers are blocked.
THD2: select ... => Still got a writer and enters cond in
query_cache_insert
THD3: select ... => Still got a writer and enters cond in
query_cache_insert
THD1: flush tables => finished and signal status change.
THD2: select ... => Wakes up and completes the insert.
THD3: select ... => Happily waiting for better times. Why hurry?
This patch is a refactoring of this lock system. It introduces four new methods:
Query_cache::try_lock()
Query_cache::lock()
Query_cache::lock_and_suspend()
Query_cache::unlock()
This change also deprecates wait_while_table_flush_is_in_progress(). All threads are
queued and put on a conditional wait. On each unlock the queue is signalled. This resolve
the issues with left over threads. To assure that no threads are spending unnecessary
time waiting a signal broadcast is issued every time a lock is taken before a full
cache flush.
2009-06-16 10:34:47 +02:00
..
2008-11-18 11:31:03 +05:30
2009-06-02 11:07:17 +02:00
2008-12-17 15:01:34 -05:00
2007-10-09 17:56:32 -04:00
2007-10-09 17:56:32 -04:00
2007-10-09 17:56:32 -04:00
2009-02-13 11:41:47 -05:00
2008-05-09 09:43:02 +02:00
2008-11-10 21:21:49 +01:00
2007-08-15 19:08:44 +04:00
2009-02-13 11:41:47 -05:00
2008-11-10 21:21:49 +01:00
2008-05-09 09:43:02 +02:00
2007-08-15 19:08:44 +04:00
2008-10-07 19:20:13 +02:00
2007-08-15 19:08:44 +04:00
2009-04-09 14:22:06 +08:00
2007-08-15 19:08:44 +04:00
2009-06-09 18:44:26 +02:00
2009-06-09 18:44:26 +02:00
2009-06-09 18:11:21 +02:00
2009-01-09 14:04:47 +02:00
2009-02-13 11:41:47 -05:00
2009-06-09 18:11:21 +02:00
2009-05-30 21:32:28 +08:00
2007-09-11 16:17:28 +02:00
2008-03-29 09:52:16 +02:00
2008-03-10 07:07:56 +01:00
2008-10-23 21:27:09 +02:00
2008-02-04 15:40:04 +01:00
2009-02-20 16:56:32 +01:00
2009-01-05 18:10:20 +02:00
2009-06-09 18:44:26 +02:00
2009-05-04 15:30:15 +05:30
2007-10-11 13:29:09 -04:00
2008-04-03 13:14:57 -04:00
2007-10-11 13:29:09 -04:00
2009-06-09 18:44:26 +02:00
2008-12-12 15:13:11 +04:00
2009-03-24 18:27:33 +00:00
2007-08-15 17:43:08 +04:00
2009-06-09 18:44:26 +02:00
2009-05-22 01:22:46 +05:00
2009-04-29 07:59:10 +05:00
2008-02-22 13:30:33 +03:00
2008-02-22 13:30:33 +03:00
2008-02-22 13:30:33 +03:00
2009-06-01 16:43:16 +04:00
2009-06-01 16:00:38 +04:00
2009-06-09 18:44:26 +02:00
2008-02-22 13:30:33 +03:00
2009-06-09 18:44:26 +02:00
2008-12-09 20:35:02 +02:00
2009-06-09 18:44:26 +02:00
2009-02-07 16:50:31 +01:00
2009-04-01 13:40:33 +05:00
2007-11-21 16:00:09 +04:00
2009-06-09 18:11:21 +02:00
2009-05-25 11:00:40 +03:00
2008-10-10 12:01:01 +02:00
2008-02-12 10:43:38 +01:00
2009-04-14 13:20:13 -04:00
2009-02-13 11:41:47 -05:00
2007-12-05 20:00:14 +01:00
2009-06-09 18:44:26 +02:00
2009-05-30 21:32:28 +08:00
2009-05-31 17:15:35 +08:00
2009-05-30 21:32:28 +08:00
2008-12-17 15:01:34 -05:00
2008-10-23 15:28:53 +02:00
2008-10-23 15:28:53 +02:00
2008-10-23 15:28:53 +02:00
2007-10-11 13:29:09 -04:00
2008-10-23 15:28:53 +02:00
2008-11-27 12:33:04 +01:00
2008-05-20 11:38:17 +04:00
2009-06-05 13:23:58 +02:00
2008-06-17 17:57:04 +05:30
2007-10-16 16:11:50 -04:00
2009-06-08 19:05:24 -03:00
2009-02-13 11:41:47 -05:00
2008-11-22 01:10:38 +01:00
2008-11-22 01:10:38 +01:00
2009-06-09 18:44:26 +02:00
2008-08-25 21:18:22 +04:00
2009-06-09 18:44:26 +02:00
2009-04-13 18:09:10 +05:00
2009-04-13 18:09:10 +05:00
2008-12-02 11:18:01 +01:00
2008-11-10 21:21:49 +01:00
2009-06-01 16:00:38 +04:00
2007-10-11 14:37:45 -04:00
2008-03-21 17:48:28 +02:00
2009-03-19 09:44:58 -04:00
2007-12-20 22:11:37 +01:00
2008-07-15 21:46:02 +04:00
2009-01-09 13:49:24 +01:00
2007-08-16 08:52:50 +02:00
2008-12-29 17:04:10 +01:00
2009-04-29 07:59:10 +05:00
2008-02-19 14:43:01 +03:00
2007-12-14 15:21:37 +02:00
2007-08-16 08:52:50 +02:00
2007-08-16 07:37:50 +02:00
2007-08-16 07:37:50 +02:00
2009-03-05 20:54:53 +01:00
2008-01-31 14:54:03 +02:00
2009-04-19 02:21:33 +01:00
2009-02-21 09:36:07 +00:00
2008-08-20 19:06:31 +05:00
2008-08-20 19:06:31 +05:00
2008-06-30 22:11:18 +02:00
2009-03-25 12:53:56 +02:00
2007-11-14 16:12:46 -05:00
2009-05-15 16:33:08 +05:30
2009-03-14 21:58:23 +03:00
2009-06-09 18:44:26 +02:00
2009-04-28 14:46:07 +03:00
2008-07-03 23:41:22 +04:00
2008-07-03 23:41:22 +04:00
2009-05-30 21:32:28 +08:00
2009-04-29 07:59:10 +05:00
2009-04-29 07:59:10 +05:00
2009-04-29 07:59:10 +05:00
2008-01-23 15:36:57 -07:00
2008-01-23 13:26:41 -07:00
2009-05-30 21:32:28 +08:00
2009-05-29 15:37:54 +02:00
2009-02-10 17:47:54 -05:00
2009-02-13 11:41:47 -05:00
2009-06-04 10:54:23 +05:00
2009-05-29 15:37:54 +02:00
2008-03-29 17:50:46 +02:00
2008-03-21 17:48:28 +02:00
2007-10-18 14:32:43 +04:00
2009-05-30 21:32:28 +08:00
2009-01-09 13:49:24 +01:00
2008-01-29 14:14:34 +03:00
2009-06-16 10:34:47 +02:00
2009-06-16 10:34:47 +02:00
2009-06-08 19:05:24 -03:00
2009-06-08 19:05:24 -03:00
2009-06-08 19:05:24 -03:00
2009-04-23 12:43:42 +05:00
2009-04-23 12:43:42 +05:00
2008-12-10 18:16:21 +04:00
2007-10-16 16:11:50 -04:00
2009-05-30 21:32:28 +08:00
2009-05-30 21:32:28 +08:00
2009-05-27 18:19:44 +03:00
2008-02-19 15:45:21 +03:00
2009-02-13 11:41:47 -05:00
2009-04-17 13:46:27 +05:00
2009-02-10 17:47:54 -05:00
2009-06-05 01:30:08 +02:00
2009-05-27 18:19:44 +03:00
2009-05-27 18:19:44 +03:00
2008-08-11 16:44:13 -06:00
2009-05-30 21:32:28 +08:00
2008-12-23 18:08:04 +04:00
2008-12-04 19:41:53 +01:00
2007-10-23 14:27:11 +05:00
2009-06-05 13:23:58 +02:00
2009-04-01 10:34:59 +05:00
2007-11-20 11:21:00 +01:00
2009-05-18 10:10:30 +02:00
2009-05-14 14:03:33 +02:00
2009-06-05 13:23:58 +02:00
2009-05-15 16:13:54 +03:00
2009-05-05 17:03:23 -04:00
2009-05-19 09:25:36 +05:00
2009-04-30 15:28:07 +03:00
2008-03-14 18:38:54 +01:00
2009-06-08 01:40:53 +05:00
2009-02-23 19:16:48 +03:00
2009-03-20 16:27:53 +02:00
2009-05-05 17:03:23 -04:00
2008-11-10 21:21:49 +01:00
2009-05-21 13:06:43 +05:00
2008-08-11 16:44:13 -06:00
2009-06-02 11:07:17 +02:00
2009-04-14 14:05:32 +02:00
2009-03-27 13:19:50 +08:00
2009-01-14 18:50:51 +04:00
2009-02-13 11:41:47 -05:00
2007-07-06 16:18:49 +04:00
2009-05-15 12:11:07 +05:00
2009-05-30 21:32:28 +08:00
2009-05-30 21:32:28 +08:00
2009-04-13 18:09:10 +05:00
2009-06-01 16:00:38 +04:00
2009-03-14 21:58:23 +03:00
2009-01-21 13:45:23 -05:00
2009-05-27 18:19:44 +03:00
2009-01-05 18:10:20 +02:00
2008-08-12 17:05:19 -06:00
2007-08-27 12:33:57 +03:00
2009-03-19 11:44:57 +01:00
2008-12-01 17:22:16 +02:00
2009-02-13 11:41:47 -05:00
2007-10-17 17:54:11 -04:00
2009-02-13 11:41:47 -05:00
2009-05-04 22:33:23 +02:00
2008-08-25 17:11:59 +05:00