summaryrefslogtreecommitdiff
path: root/sql/sql_cache.cc
diff options
context:
space:
mode:
authorVicențiu Ciorbaru <vicentiu@mariadb.org>2018-01-24 12:29:31 +0200
committerVicențiu Ciorbaru <vicentiu@mariadb.org>2018-01-24 12:29:31 +0200
commitd833bb65d53b9a4375fa71cc485b4719fdb0ee53 (patch)
treed1271339e1c3a660e4788a5c9913bfe54e0271f1 /sql/sql_cache.cc
parente431d90065d277e62fa4f81a1654790f58a84146 (diff)
parent76577e1e2602f3c30859a176808c433a263e1b0a (diff)
downloadmariadb-git-d833bb65d53b9a4375fa71cc485b4719fdb0ee53.tar.gz
Merge remote-tracking branch '5.5' into 10.0
Diffstat (limited to 'sql/sql_cache.cc')
-rw-r--r--sql/sql_cache.cc19
1 files changed, 18 insertions, 1 deletions
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 109150ef0d5..8bfef270f4a 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -1191,7 +1191,11 @@ void Query_cache::end_of_result(THD *thd)
#endif
if (try_lock(thd, Query_cache::WAIT))
+ {
+ if (is_disabled())
+ query_cache_tls->first_query_block= NULL; // do not try again with QC
DBUG_VOID_RETURN;
+ }
query_block= query_cache_tls->first_query_block;
if (query_block)
@@ -1563,6 +1567,8 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
unlock();
+ DEBUG_SYNC(thd, "wait_in_query_cache_store_query");
+
// init_n_lock make query block locked
BLOCK_UNLOCK_WR(query_block);
}
@@ -2741,13 +2747,17 @@ void Query_cache::make_disabled()
This function frees all resources allocated by the cache. You
have to call init_cache() before using the cache again. This function
- requires the structure_guard_mutex to be locked.
+ requires the cache to be locked (LOCKED_NO_WAIT, lock_and_suspend) or
+ disabling.
*/
void Query_cache::free_cache()
{
DBUG_ENTER("Query_cache::free_cache");
+ DBUG_ASSERT(m_cache_lock_status == LOCKED_NO_WAIT ||
+ m_cache_status == DISABLE_REQUEST);
+
/* Destroy locks */
Query_cache_block *block= queries_blocks;
if (block)
@@ -2755,6 +2765,13 @@ void Query_cache::free_cache()
do
{
Query_cache_query *query= block->query();
+ /*
+ There will not be new requests but some maybe not finished yet,
+ so wait for them by trying lock/unlock
+ */
+ BLOCK_LOCK_WR(block);
+ BLOCK_UNLOCK_WR(block);
+
mysql_rwlock_destroy(&query->lock);
block= block->next;
} while (block != queries_blocks);