summaryrefslogtreecommitdiff
path: root/sql/sql_cache.cc
diff options
context:
space:
mode:
authorDavi Arnaut <davi.arnaut@oracle.com>2010-10-08 09:16:20 -0300
committerDavi Arnaut <davi.arnaut@oracle.com>2010-10-08 09:16:20 -0300
commit15ccca1d5520eca44fd63925fdd2020428965985 (patch)
treef3b1c0750f4c6f092874c062ab7a0a8352089f0a /sql/sql_cache.cc
parentc8d7a31f35bc988362ec07c2e2520a0dc511eebe (diff)
downloadmariadb-git-15ccca1d5520eca44fd63925fdd2020428965985.tar.gz
Bug#56822: Add a thread state for sessions waiting on the query cache lock
Only wait for a single debug signal at a time as the signal state is global. Also, do not activate the query cache debug sync points if the thread has no associated THD session. mysql-test/t/query_cache_debug.test: Only wait for a single debug signal at a time as the signal state is global. sql/sql_cache.cc: Do not execute the debug sync point if the thread has no associated THD session. This scenario happens for federated threads.
Diffstat (limited to 'sql/sql_cache.cc')
-rw-r--r--sql/sql_cache.cc22
1 files changed, 19 insertions, 3 deletions
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 8c3abdbf1b0..9876c46bbb3 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -385,6 +385,22 @@ TODO list:
/**
+ Macro that executes the requested action at a synchronization point
+ only if the thread has a associated THD session.
+*/
+#if defined(ENABLED_DEBUG_SYNC)
+#define QC_DEBUG_SYNC(name) \
+ do { \
+ THD *thd= current_thd; \
+ if (thd) \
+ DEBUG_SYNC(thd, name); \
+ } while (0)
+#else
+#define QC_DEBUG_SYNC(name)
+#endif
+
+
+/**
Thread state to be used when the query cache lock needs to be acquired.
Sets the thread state name in the constructor, resets on destructor.
*/
@@ -879,7 +895,7 @@ Query_cache::insert(Query_cache_tls *query_cache_tls,
if (is_disabled() || query_cache_tls->first_query_block == NULL)
DBUG_VOID_RETURN;
- DEBUG_SYNC(current_thd, "wait_in_query_cache_insert");
+ QC_DEBUG_SYNC("wait_in_query_cache_insert");
if (try_lock())
DBUG_VOID_RETURN;
@@ -1975,7 +1991,7 @@ void Query_cache::flush()
if (is_disabled())
DBUG_VOID_RETURN;
- DEBUG_SYNC(current_thd, "wait_in_query_cache_flush1");
+ QC_DEBUG_SYNC("wait_in_query_cache_flush1");
lock_and_suspend();
if (query_cache_size > 0)
@@ -2315,7 +2331,7 @@ void Query_cache::free_cache()
void Query_cache::flush_cache()
{
- DEBUG_SYNC(current_thd, "wait_in_query_cache_flush2");
+ QC_DEBUG_SYNC("wait_in_query_cache_flush2");
my_hash_reset(&queries);
while (queries_blocks != 0)