summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMichael Widenius <monty@mariadb.org>2019-06-17 17:50:08 +0300
committerMichael Widenius <monty@mariadb.org>2019-06-17 17:50:08 +0300
commitc8b5fa4afc6c233101b8163ef19c1abc1be0373d (patch)
tree377b25b9207e3b3d5e1a0f5ab0b63cc1cfb3b685 /sql
parent2b660fb4c212973ba0f118b47336b608d091f327 (diff)
downloadmariadb-git-c8b5fa4afc6c233101b8163ef19c1abc1be0373d.tar.gz
MDEV-19055 Failures with temporary tables and Aria
There was two separate problems: - Aria pagecache didn't properly handle re-reading of blocks that have given errors before (this triggered an assert) - temporary tables that where opened several times where not properly closed in ALTER, REPAIR or OPTIMIZE table Other things - Added a couple of asserts that will make it easier to find problems like this in the future.
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_admin.cc28
-rw-r--r--sql/sql_table.cc2
2 files changed, 18 insertions, 12 deletions
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc
index ed5ba93c3fe..ab95fdc340c 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -697,19 +697,23 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
MDL_SHARED_NO_READ_WRITE lock (MDL_SHARED_WRITE cannot be upgraded)
by *not* having HA_CONCURRENT_OPTIMIZE table_flag.
*/
- if (lock_type == TL_WRITE && !table->table->s->tmp_table &&
- table->mdl_request.type > MDL_SHARED_WRITE)
+ if (lock_type == TL_WRITE && table->mdl_request.type > MDL_SHARED_WRITE)
{
- if (wait_while_table_is_used(thd, table->table, HA_EXTRA_NOT_USED))
- goto err;
- DEBUG_SYNC(thd, "after_admin_flush");
- /* Flush entries in the query cache involving this table. */
- query_cache_invalidate3(thd, table->table, 0);
- /*
- XXX: hack: switch off open_for_modify to skip the
- flush that is made later in the execution flow.
- */
- open_for_modify= 0;
+ if (table->table->s->tmp_table)
+ thd->close_unused_temporary_table_instances(tables);
+ else
+ {
+ if (wait_while_table_is_used(thd, table->table, HA_EXTRA_NOT_USED))
+ goto err;
+ DEBUG_SYNC(thd, "after_admin_flush");
+ /* Flush entries in the query cache involving this table. */
+ query_cache_invalidate3(thd, table->table, 0);
+ /*
+ XXX: hack: switch off open_for_modify to skip the
+ flush that is made later in the execution flow.
+ */
+ open_for_modify= 0;
+ }
}
if (table->table->s->crashed && operator_func == &handler::ha_check)
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index a64e17e2d3b..522d18b3701 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -9536,6 +9536,8 @@ do_continue:;
DEBUG_SYNC(thd, "alter_table_copy_after_lock_upgrade");
}
+ else
+ thd->close_unused_temporary_table_instances(table_list);
// It's now safe to take the table level lock.
if (lock_tables(thd, table_list, alter_ctx.tables_opened, 0))