summaryrefslogtreecommitdiff
path: root/sql/wsrep_mysqld.cc
diff options
context:
space:
mode:
authorsjaakola <seppo.jaakola@iki.fi>2020-11-09 12:41:52 +0200
committerJan Lindström <jan.lindstrom@mariadb.com>2020-11-11 17:46:50 +0200
commit2fbcddbeafb558720f4b74b0a8f68c18b48d9f2e (patch)
tree5740c9811a508311f71f99933a633de7ea4a2af9 /sql/wsrep_mysqld.cc
parentad432ef4c0b81cf796f9b1f66848a3cde6becf77 (diff)
downloadmariadb-git-2fbcddbeafb558720f4b74b0a8f68c18b48d9f2e.tar.gz
MDEV-24119 MDL BF-BF Conflict caused by TRUNCATE TABLE
A follow-up fix, for original fix for MDEV-21577, which did not handle well temporary tables. OPTIMIZE and REPAIR TABLE statements can take a list of tables as argument, and some of the tables may be temporary. Proper handling of temporary tables is to skip them and continue working on the real tables. The bad version, skipped all tables, if a single temporary table was in the argument list. And this resulted so that FK parent tables were not scnanned for the remaining real tables. Some mtr tests, using OPTIMIZE or REPAIR for temporary tables caused regressions bacause of this, e.g. galera.galera_optimize_analyze_multi The fix in this PR opens temporary and real tables first, and in the table handling loop skips temporary tables, FK parent scanning is done only for real tables. The test has new scenario for OPTIMIZE and REPAIR issued for two tables of which one is temporary table. Reviewed-by: Jan Lindström <jan.lindstrom@mariadb.com>
Diffstat (limited to 'sql/wsrep_mysqld.cc')
-rw-r--r--sql/wsrep_mysqld.cc35
1 files changed, 16 insertions, 19 deletions
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index 304da7ec979..99a8105efd9 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -1191,30 +1191,27 @@ wsrep_append_fk_parent_table(THD* thd, TABLE_LIST* tables, wsrep::key_array* key
uint counter;
MDL_savepoint mdl_savepoint= thd->mdl_context.mdl_savepoint();
- bool open_error=
- open_tables(thd, &tables, &counter, MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL);
- if (unlikely(open_error && (thd->killed || thd->is_error())))
+ if (thd->open_temporary_tables(tables) ||
+ open_tables(thd, &tables, &counter, MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL))
{
- WSREP_WARN("unable to open table for FK checks in OPTIMIZE/REPAIR/ALTER processing");
+ WSREP_DEBUG("unable to open table for FK checks for %s", thd->query());
}
- else
+
+ for (table= tables; table; table= table->next_local)
{
- for (table= tables; table; table= table->next_local)
+ if (!is_temporary_table(table) && table->table)
{
- if (table->table)
+ FOREIGN_KEY_INFO *f_key_info;
+ List<FOREIGN_KEY_INFO> f_key_list;
+
+ table->table->file->get_foreign_key_list(thd, &f_key_list);
+ List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list);
+ while ((f_key_info=it++))
{
- FOREIGN_KEY_INFO *f_key_info;
- List<FOREIGN_KEY_INFO> f_key_list;
-
- table->table->file->get_foreign_key_list(thd, &f_key_list);
- List_iterator_fast<FOREIGN_KEY_INFO> it(f_key_list);
- while ((f_key_info=it++))
- {
- WSREP_DEBUG("appended fkey %s", f_key_info->referenced_table->str);
- keys->push_back(wsrep_prepare_key_for_toi(f_key_info->referenced_db->str,
- f_key_info->referenced_table->str,
- wsrep::key::shared));
- }
+ WSREP_DEBUG("appended fkey %s", f_key_info->referenced_table->str);
+ keys->push_back(wsrep_prepare_key_for_toi(f_key_info->referenced_db->str,
+ f_key_info->referenced_table->str,
+ wsrep::key::shared));
}
}
}