From 7141c260948ab48702482b350797638877130fbf Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 25 Nov 2022 16:27:24 +1100 Subject: 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. --- sql/sql_table.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sql/sql_table.cc') 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) -- cgit v1.2.1