summaryrefslogtreecommitdiff
path: root/sql/sql_cache.cc
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2018-01-12 18:17:55 +0100
committerOleksandr Byelkin <sanja@mariadb.com>2018-01-12 18:17:55 +0100
commitf26192559161143c7c0880cf24c63ced1cf9655e (patch)
treec2d1b46c6a02ecac0eeae962de854d757c1fb118 /sql/sql_cache.cc
parent5ea28015d5864bec1e44722bbc7a3d1f2371c85d (diff)
downloadmariadb-git-bb-5.5-MDEV-14526.tar.gz
MDEV-14526: MariaDB keeps crashing under load when query_cache_type is changedbb-5.5-MDEV-14526
The problem was in such scenatio: T1 - starts geristering query and locked QC T2 - starts disabling QC and wait for UNLOCK T1 - unlock QC T2 - disable QC and destroy sugnals without waitiung for query unlock T1 a) - not yet unlocked query in qc and crach on attempt to unlock because QC signals are destroyed b) if above was done before distruction, it execute end_of results first time it exit on after try_lock which see QC disables and return TRUE. But it do not reset query_cache_tls->first_query_block which lead to second call of end_of_result when diagnostic arena has already inapropriate staus (not is_eof()). Fix is: 1) wait for all queries unlocked before destroing them by locking and unlockin 2) remove query_cache_tls->first_query_block if QC disabled
Diffstat (limited to 'sql/sql_cache.cc')
-rw-r--r--sql/sql_cache.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 2ec870f314f..eb6aec8b15a 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -1184,7 +1184,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)
@@ -1556,6 +1560,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);
}
@@ -2693,6 +2699,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);