MDEV-16929 Assertion ... in close_thread_tables upon killing connection

Problem was that the code didn't handle a transaction created in innodb
as part of a failed mysql_lock_tables()
This commit is contained in:
Monty 2020-07-21 15:12:53 +03:00
parent af83ed9f0e
commit e26c822aa0
3 changed files with 36 additions and 0 deletions

View file

@ -0,0 +1,12 @@
#
# MDEV-16929 Assertion ... in close_thread_tables upon killing connection
# running SHOW on sequence
#
CREATE SEQUENCE s ENGINE=InnoDB;
RENAME TABLE s TO s1;
connect con1,localhost,root,,test;
SHOW CREATE SEQUENCE s1;
connection default;
KILL thread_id;
connection default;
drop sequence s1;

View file

@ -0,0 +1,20 @@
--source include/have_innodb.inc
--echo #
--echo # MDEV-16929 Assertion ... in close_thread_tables upon killing connection
--echo # running SHOW on sequence
--echo #
CREATE SEQUENCE s ENGINE=InnoDB;
RENAME TABLE s TO s1;
--connect (con1,localhost,root,,test)
--let $conid= `SELECT CONNECTION_ID()`
--send
SHOW CREATE SEQUENCE s1;
--connection default
--replace_result $conid thread_id
--eval KILL $conid
# Cleanup
--connection default
drop sequence s1;

View file

@ -485,6 +485,10 @@ int SEQUENCE::read_initial_values(TABLE *table)
if (mdl_lock_used)
thd->mdl_context.release_lock(mdl_request.ticket);
write_unlock(table);
if (!has_active_transaction && !thd->transaction.stmt.is_empty() &&
!thd->in_sub_stmt)
trans_commit_stmt(thd);
DBUG_RETURN(HA_ERR_LOCK_WAIT_TIMEOUT);
}
DBUG_ASSERT(table->reginfo.lock_type == TL_READ);