Merge bb-10.2-ext into 10.3

This commit is contained in:
Marko Mäkelä 2018-02-15 10:22:03 +02:00
commit b006d2ead4
583 changed files with 17030 additions and 5583 deletions

View file

@ -1187,7 +1187,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)
@ -1564,6 +1568,8 @@ def_week_frmt: %zu, 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);
}
@ -2573,6 +2579,7 @@ void Query_cache::init()
*/
if (global_system_variables.query_cache_type == 0)
{
m_cache_status= DISABLE_REQUEST;
free_cache();
m_cache_status= DISABLED;
}
@ -2781,13 +2788,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)
@ -2795,6 +2806,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);