summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2021-05-26 14:35:23 +0300
committerMonty <monty@mariadb.org>2021-05-26 14:35:23 +0300
commitaa284e02374c2abdb9ae660c232c076276d2ce98 (patch)
treefeecc857f2ee83b9a50b1dd5835924f7cca519ac /sql/sql_base.cc
parent1864a8ea93aa1d1a540c83526a25df2ad0330763 (diff)
downloadmariadb-git-aa284e02374c2abdb9ae660c232c076276d2ce98.tar.gz
MDEV-17749 Kill during LOCK TABLE ; ALTER TABLE causes assert
The problem was that when LOCK TABLES where unwinded as part of a killed connection, unlink_all_closed_tables() did not like that there was uncommited transactions. Fixed by doing a rollback of any open transaction in this particular case.
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r--sql/sql_base.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index f793556cf62..e80a78ff802 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2469,7 +2469,17 @@ unlink_all_closed_tables(THD *thd, MYSQL_LOCK *lock, size_t reopen_count)
/* If no tables left, do an automatic UNLOCK TABLES */
if (thd->lock && thd->lock->table_count == 0)
+ {
+ /*
+ We have to rollback any open transactions here.
+ This is required in the case where the server has been killed
+ but some transations are still open (as part of locked tables).
+ If we don't do this, we will get an assert in unlock_locked_tables().
+ */
+ ha_rollback_trans(thd, FALSE);
+ ha_rollback_trans(thd, TRUE);
unlock_locked_tables(thd);
+ }
}