mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Bug#28211 RENAME DATABASE and query cache don't play nicely together
When all table blocks were removed from the query cache the client session hung in a tight loop waiting on an impossible condition while consuming a lot of CPU. This patch also corrects an error which caused valid tables to sometimes be removed from the query cache. mysql-test/r/query_cache.result: Added test case to make sure server doesn't hang in a tight loop if last table block is removed from the cache. mysql-test/t/query_cache.test: Added test case to make sure server doesn't hang in a tight loop if last table block is removed from the cache. sql/sql_cache.cc: - Refactored loop over table blocks. The invalidate_table() function effects the elements over which we iterate. The previous stop condition was broken due to a compiler optimization error probably caused by the goto-statement pointing out of the loop. The effect being that tables_blocks was never checked for null values and thus the loop never terminated. - The new implementation uses two while loops instead of a goto-statement. The tables_blocks is a circular list which becomes null if the last table block is removed from the list.
This commit is contained in:
@ -1000,3 +1000,48 @@ set GLOBAL query_cache_min_res_unit=default;
|
||||
set GLOBAL query_cache_size= default;
|
||||
|
||||
# End of 5.0 tests
|
||||
|
||||
|
||||
#
|
||||
# Bug #28211 RENAME DATABASE and query cache don't play nicely together
|
||||
#
|
||||
--disable_warnings
|
||||
drop database if exists db1;
|
||||
drop database if exists db2;
|
||||
--enable_warnings
|
||||
set GLOBAL query_cache_size=15*1024*1024;
|
||||
create database db1;
|
||||
use db1;
|
||||
create table t1(c1 int)engine=myisam;
|
||||
insert into t1(c1) values (1);
|
||||
select * from db1.t1 f;
|
||||
show status like 'Qcache_queries_in_cache';
|
||||
rename schema db1 to db2;
|
||||
show status like 'Qcache_queries_in_cache';
|
||||
drop database db2;
|
||||
set global query_cache_size=default;
|
||||
|
||||
--disable_warnings
|
||||
drop database if exists db1;
|
||||
drop database if exists db3;
|
||||
--enable_wearnings
|
||||
set GLOBAL query_cache_size=15*1024*1024;
|
||||
create database db1;
|
||||
create database db3;
|
||||
use db1;
|
||||
create table t1(c1 int) engine=myisam;
|
||||
use db3;
|
||||
create table t1(c1 int) engine=myisam;
|
||||
use db1;
|
||||
insert into t1(c1) values (1);
|
||||
use mysql;
|
||||
select * from db1.t1;
|
||||
select c1+1 from db1.t1;
|
||||
select * from db3.t1;
|
||||
show status like 'Qcache_queries_in_cache';
|
||||
rename schema db1 to db2;
|
||||
show status like 'Qcache_queries_in_cache';
|
||||
drop database db2;
|
||||
drop database db3;
|
||||
|
||||
# End of 5.1 tests
|
||||
|
Reference in New Issue
Block a user