diff options
author | Dmitry Lenev <dlenev@mysql.com> | 2010-08-31 13:04:19 +0400 |
---|---|---|
committer | Dmitry Lenev <dlenev@mysql.com> | 2010-08-31 13:04:19 +0400 |
commit | 26bc3b34d5c50599bd6f9856b19c9c4e4c58d819 (patch) | |
tree | 200cec1f722fc1875fd49dcbda9d0b84e1c38aa3 /sql/sp.cc | |
parent | 0142c14a6b3fd551e5b8e8dc5fd61e215910c72f (diff) | |
download | mariadb-git-26bc3b34d5c50599bd6f9856b19c9c4e4c58d819.tar.gz |
Bug #56137 "Assertion `thd->lock == 0' failed on upgrading
from 5.1.50 to 5.5.6".
Debug builds of the server aborted due to an assertion
failure when DROP DATABASE statement was run on an
installation which had outdated or corrupt mysql.proc table.
Particularly this affected the mysql_upgrade tool which is
run as part of 5.1 to 5.5 upgrade.
The problem was that sp_drop_db_routines(), which was invoked
during dropping of the database, could have returned without
closing and unlocking mysql.proc table in cases when this
table was not up-to-date with the current server. As a result
further attempt to open and lock the mysql.event table, which
was necessary to complete dropping of the database, ended up
with an assert.
This patch solves this problem by ensuring that
sp_drop_db_routines() always closes mysql.proc table and
releases metadata locks on it. This is achieved by changing
open_proc_table_for_update() function to close tables and
release metadata locks acquired by it in case of failure.
This step also makes behavior of the latter function
consistent with behavior of open_proc_table_for_read()/
open_and_lock_tables().
Test case for this bug was added to sp-destruct.test.
Diffstat (limited to 'sql/sp.cc')
-rw-r--r-- | sql/sp.cc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/sql/sp.cc b/sql/sp.cc index 0265ef45a2a..8821dc9365d 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -440,6 +440,7 @@ static TABLE *open_proc_table_for_update(THD *thd) { TABLE_LIST table_list; TABLE *table; + MDL_ticket *mdl_savepoint= thd->mdl_context.mdl_savepoint(); DBUG_ENTER("open_proc_table_for_update"); table_list.init_one_table("mysql", 5, "proc", 4, "proc", TL_WRITE); @@ -450,6 +451,9 @@ static TABLE *open_proc_table_for_update(THD *thd) if (!proc_table_intact.check(table, &proc_table_def)) DBUG_RETURN(table); + close_thread_tables(thd); + thd->mdl_context.rollback_to_savepoint(mdl_savepoint); + DBUG_RETURN(NULL); } |