diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2020-04-27 17:32:02 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2020-04-27 18:49:29 +0400 |
commit | c2b3a4c253a76c1aaa6ef5d96bb7995afc3a572b (patch) | |
tree | d2d288a61d4a3aafec83835e48239f167e6c6894 | |
parent | 4638d2446d74c6b416daec0ca6a08c93d35b3e8f (diff) | |
download | mariadb-git-bb-10.2-svoj.tar.gz |
MDEV-17749 - ALTER TABLE asserts under LOCK TABLESbb-10.2-svoj
Regression after 43f6e118f caused by "automatic UNLOCK TABLES if we
don't have any locked tables (safety fix)", which didn't commit (or
rollback) pending transaction prior to leaving locked tables mode.
Leaving locked tables mode is a bit more complex than calling
unlock_locked_tables(), see e.g. SQLCOM_UNLOCK_TABLES branch of
mysql_execute_command(). Also such leaving should've been done
consistently in all cases whenever a table gets unlock.
Given that the above is hardly doable in old-GA, reverted part of the
43f6e118f. It doesn't seem to be required to fix the original problem
as original test passes without this change.
-rw-r--r-- | mysql-test/suite/innodb/r/innodb-lock.result | 21 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/innodb-lock.test | 26 | ||||
-rw-r--r-- | sql/sql_base.cc | 4 |
3 files changed, 47 insertions, 4 deletions
diff --git a/mysql-test/suite/innodb/r/innodb-lock.result b/mysql-test/suite/innodb/r/innodb-lock.result index 1fe0d263fef..260880a1198 100644 --- a/mysql-test/suite/innodb/r/innodb-lock.result +++ b/mysql-test/suite/innodb/r/innodb-lock.result @@ -159,3 +159,24 @@ connection con1; disconnect con1; connection default; DROP TABLE t1, t2, t3; +# +# MDEV-17749 - Assertion `thd->transaction.stmt.is_empty()' failed in +# Locked_tables_list::unlock_locked_tables upon ALTER killed +# under lock +# +CREATE TEMPORARY TABLE t1(c INT) ENGINE=InnoDB; +LOCK TABLES t1 WRITE; +ALTER TABLE t1 ADD COLUMN c2 INT; +REPAIR TABLE t1 USE_FRM; +Table Op Msg_type Msg_text +t1 repair error Cannot repair temporary table from .frm file +UNLOCK TABLES; +DROP TABLE t1; +CREATE TABLE t1(a INT) ENGINE=InnoDB; +connect con1, localhost, root; +LOCK TABLE t1 WRITE; +ALTER TABLE t1 ADD COLUMN b INT; +connection default; +KILL conid; +disconnect con1; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb-lock.test b/mysql-test/suite/innodb/t/innodb-lock.test index 9e5505270be..e4209fe9f7b 100644 --- a/mysql-test/suite/innodb/t/innodb-lock.test +++ b/mysql-test/suite/innodb/t/innodb-lock.test @@ -219,3 +219,29 @@ reap; disconnect con1; connection default; DROP TABLE t1, t2, t3; + + +--echo # +--echo # MDEV-17749 - Assertion `thd->transaction.stmt.is_empty()' failed in +--echo # Locked_tables_list::unlock_locked_tables upon ALTER killed +--echo # under lock +--echo # +CREATE TEMPORARY TABLE t1(c INT) ENGINE=InnoDB; +LOCK TABLES t1 WRITE; +ALTER TABLE t1 ADD COLUMN c2 INT; +REPAIR TABLE t1 USE_FRM; +UNLOCK TABLES; +DROP TABLE t1; + +CREATE TABLE t1(a INT) ENGINE=InnoDB; + +connect con1, localhost, root; +LOCK TABLE t1 WRITE; +let $conid= `SELECT CONNECTION_ID()`; +send ALTER TABLE t1 ADD COLUMN b INT; + +connection default; +replace_result $conid conid; +eval KILL $conid; +disconnect con1; +DROP TABLE t1; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 678790e8bca..e0a6949fad6 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2391,10 +2391,6 @@ unlink_all_closed_tables(THD *thd, MYSQL_LOCK *lock, size_t reopen_count) m_locked_tables_count--; } } - - /* If no tables left, do an automatic UNLOCK TABLES */ - if (thd->lock && thd->lock->table_count == 0) - unlock_locked_tables(thd); } |