Commit 7141c260 authored by Daniel Black's avatar Daniel Black

MDEV-29760: DROP DATABASE hangs when particular query cache is present

Fix the regression introduced in
dfb41fdd.

In the restructure of mysql_rm_table_no_locks the early condition
of !frm_error that enabled non_tmp_table_deleted, and hence the
query cache invalidation, was removed.

The query_cache_invalidate1(thd, dbnorm) called after
mysql_rm_table_no_locks depends on the query cache removal
(for unexamined reasons).

Under DROP DATABASE, in mysql_rm_table_no_locks, dont_log_query
is true preventing the late setting of non_tmp_table_deleted
(which retained one of its purposes as a replication deletion
of temporary tables, but not query cache invalidation).

The non_temp_tables_count however can still be used to invalidate
the query cache.
parent 165564d3
......@@ -462,6 +462,27 @@ flush query cache|
delete from t1|
drop procedure bug3583|
drop table t1|
#
# MDEV-29760 DROP DATABASE hangs when particular query cache is present
#
create table t1 (id int);
create table t2 like t1;
create table t3 like t1;
create database d;
create table d.t1 like test.t1;
create table d.t2 like test.t2;
set LOCAL query_cache_type=ON;
select id from t3;
id
select 'x' a, 'y' b from d.t1;
a b
select 'x' a, 'y' b from d.t1, d.t2;
a b
drop database d;
drop table t1, t2, t3;
#
# End of 10.5 tests
#
SET GLOBAL query_cache_size=@query_cache_size_save;
SET GLOBAL query_cache_type=@query_cache_type_save;
set GLOBAL sql_mode=@sql_mode_save;
......@@ -325,6 +325,33 @@ drop procedure bug3583|
drop table t1|
delimiter ;|
--echo #
--echo # MDEV-29760 DROP DATABASE hangs when particular query cache is present
--echo #
create table t1 (id int);
create table t2 like t1;
create table t3 like t1;
create database d;
create table d.t1 like test.t1;
create table d.t2 like test.t2;
set LOCAL query_cache_type=ON;
select id from t3;
select 'x' a, 'y' b from d.t1;
select 'x' a, 'y' b from d.t1, d.t2;
drop database d;
drop table t1, t2, t3;
--echo #
--echo # End of 10.5 tests
--echo #
# Wait till we reached the initial number of concurrent sessions
--source include/wait_until_count_sessions.inc
SET GLOBAL query_cache_size=@query_cache_size_save;
......
......@@ -2691,13 +2691,16 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
}
error= thd->is_error();
if (non_temp_tables_count)
query_cache_invalidate3(thd, tables, 0);
/*
We are always logging drop of temporary tables.
The reason is to handle the following case:
- Use statement based replication
- CREATE TEMPORARY TABLE foo (logged)
- set row based replication
- DROP TEMPORAY TABLE foo (needs to be logged)
- DROP TEMPORARY TABLE foo (needs to be logged)
This should be fixed so that we remember if creation of the
temporary table was logged and only log it if the creation was
logged.
......@@ -2709,7 +2712,6 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
if (non_trans_tmp_table_deleted || trans_tmp_table_deleted)
thd->transaction->stmt.mark_dropped_temp_table();
query_cache_invalidate3(thd, tables, 0);
if (!dont_log_query && mysql_bin_log.is_open())
{
if (non_trans_tmp_table_deleted)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment