From ab8ffbc8db1c05adfacdfbeb4c6fb15fc9b6dc9e Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Thu, 22 Aug 2019 23:36:53 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20#14245=20Advisor=20fails=20on=20MySQL=20?= =?UTF-8?q?=E2=89=A58.0.3=20as=20many=20MySQL=20variables=20were=20removed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As many MySQL variables were removed, we need to disable the rules using these variables. For this, a variable identifying MySQL had been created and is used with the MySQL version to check if the rule should be checked or not. Signed-off-by: Hugues Peccatte --- libraries/advisory_rules.txt | 14 +++++++------- libraries/classes/Advisor.php | 4 ++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/libraries/advisory_rules.txt b/libraries/advisory_rules.txt index 46446c0b8bac..875a99b1d763 100644 --- a/libraries/advisory_rules.txt +++ b/libraries/advisory_rules.txt @@ -143,7 +143,7 @@ rule 'MySQL Architecture' # Query cache # Lame: 'ON' == 0 is true, so you need to compare 'ON' == '0' -rule 'Query cache disabled' +rule 'Query cache disabled' [IS_MYSQL == false || PMA_MYSQL_INT_VERSION < 80003] query_cache_size value == 0 || query_cache_type == 'OFF' || query_cache_type == '0' The query cache is not enabled. @@ -157,42 +157,42 @@ rule 'Query caching method' [!fired('Query cache disabled')] You are using the MySQL Query cache with a fairly high traffic database. It might be worth considering to use memcached instead of the MySQL Query cache, especially if you have multiple slaves. The query cache is enabled and the server receives %d queries per second. This rule fires if there is more than 100 queries per second. | round(value,1) -rule 'Query cache efficiency (%)' [Com_select + Qcache_hits > 0 && !fired('Query cache disabled')] +rule 'Query cache efficiency (%)' [(IS_MYSQL == false || PMA_MYSQL_INT_VERSION < 80003) && Com_select + Qcache_hits > 0 && !fired('Query cache disabled')] Qcache_hits / (Com_select + Qcache_hits) * 100 value < 20 Query cache not running efficiently, it has a low hit rate. Consider increasing {query_cache_limit}. The current query cache hit rate of %s% is below 20% | round(value,1) -rule 'Query Cache usage' [!fired('Query cache disabled')] +rule 'Query Cache usage' [(IS_MYSQL == false || PMA_MYSQL_INT_VERSION < 80003) && !fired('Query cache disabled')] 100 - Qcache_free_memory / query_cache_size * 100 value < 80 Less than 80% of the query cache is being utilized. This might be caused by {query_cache_limit} being too low. Flushing the query cache might help as well. The current ratio of free query cache memory to total query cache size is %s%. It should be above 80% | round(value,1) -rule 'Query cache fragmentation' [!fired('Query cache disabled')] +rule 'Query cache fragmentation' [(IS_MYSQL == false || PMA_MYSQL_INT_VERSION < 80003) && !fired('Query cache disabled')] Qcache_free_blocks / (Qcache_total_blocks / 2) * 100 value > 20 The query cache is considerably fragmented. Severe fragmentation is likely to (further) increase Qcache_lowmem_prunes. This might be caused by many Query cache low memory prunes due to {query_cache_size} being too small. For a immediate but short lived fix you can flush the query cache (might lock the query cache for a long time). Carefully adjusting {query_cache_min_res_unit} to a lower value might help too, e.g. you can set it to the average size of your queries in the cache using this formula: (query_cache_size - qcache_free_memory) / qcache_queries_in_cache The cache is currently fragmented by %s% , with 100% fragmentation meaning that the query cache is an alternating pattern of free and used blocks. This value should be below 20%. | round(value,1) -rule 'Query cache low memory prunes' [Qcache_inserts > 0 && !fired('Query cache disabled')] +rule 'Query cache low memory prunes' [(IS_MYSQL == false || PMA_MYSQL_INT_VERSION < 80003) && Qcache_inserts > 0 && !fired('Query cache disabled')] Qcache_lowmem_prunes / Qcache_inserts * 100 value > 0.1 Cached queries are removed due to low query cache memory from the query cache. You might want to increase {query_cache_size}, however keep in mind that the overhead of maintaining the cache is likely to increase with its size, so do this in small increments and monitor the results. The ratio of removed queries to inserted queries is %s%. The lower this value is, the better (This rules firing limit: 0.1%) | round(value,1) -rule 'Query cache max size' [!fired('Query cache disabled')] +rule 'Query cache max size' [(IS_MYSQL == false || PMA_MYSQL_INT_VERSION < 80003) && !fired('Query cache disabled')] query_cache_size value > 1024 * 1024 * 128 The query cache size is above 128 MiB. Big query caches may cause significant overhead that is required to maintain the cache. Depending on your environment, it might be performance increasing to reduce this value. Current query cache size: %s | ADVISOR_formatByteDown(value, 2, 2) -rule 'Query cache min result size' [!fired('Query cache disabled')] +rule 'Query cache min result size' [(IS_MYSQL == false || PMA_MYSQL_INT_VERSION < 80003) && !fired('Query cache disabled')] query_cache_limit value == 1024*1024 The max size of the result set in the query cache is the default of 1 MiB. diff --git a/libraries/classes/Advisor.php b/libraries/classes/Advisor.php index b9e0e6400ff4..68c819445406 100644 --- a/libraries/classes/Advisor.php +++ b/libraries/classes/Advisor.php @@ -221,6 +221,10 @@ public function run() $this->variables['system_memory'] = isset($memory['MemTotal']) ? $memory['MemTotal'] : 0; + // Add IS_MYSQL to globals + $isMariaDB = false !== strpos($this->getVariables()['version'], 'MariaDB'); + $this->globals['IS_MYSQL'] = !$isMariaDB; + // Step 2: Read and parse the list of rules $this->setParseResult(static::parseRulesFile()); // Step 3: Feed the variables to the rules and let them fire. Sets