diff options
author | Daniel Black <daniel@mariadb.org> | 2022-11-25 16:27:24 +1100 |
---|---|---|
committer | Daniel Black <daniel@mariadb.org> | 2022-11-26 04:05:19 +1100 |
commit | 7141c260948ab48702482b350797638877130fbf (patch) | |
tree | 757c77c0a1224a8170c681f74ff6ab7ea7de952e | |
parent | 165564d3c33ae3d677d70644a83afcb744bdbf65 (diff) | |
download | mariadb-git-7141c260948ab48702482b350797638877130fbf.tar.gz |
MDEV-29760: DROP DATABASE hangs when particular query cache is present
Fix the regression introduced in
dfb41fddf69ccbca89fd322901f2809bc3bcc0e9.
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.
-rw-r--r-- | mysql-test/main/query_cache_notembedded.result | 21 | ||||
-rw-r--r-- | mysql-test/main/query_cache_notembedded.test | 27 | ||||
-rw-r--r-- | sql/sql_table.cc | 6 |
3 files changed, 52 insertions, 2 deletions
diff --git a/mysql-test/main/query_cache_notembedded.result b/mysql-test/main/query_cache_notembedded.result index 29a091b68c1..3477161e9cf 100644 --- a/mysql-test/main/query_cache_notembedded.result +++ b/mysql-test/main/query_cache_notembedded.result @@ -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; diff --git a/mysql-test/main/query_cache_notembedded.test b/mysql-test/main/query_cache_notembedded.test index 03c9d9e4cd4..83c7b1628e8 100644 --- a/mysql-test/main/query_cache_notembedded.test +++ b/mysql-test/main/query_cache_notembedded.test @@ -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; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 1ca09332872..499d7552b43 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2691,13 +2691,16 @@ err: } 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 @@ err: 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) |