summaryrefslogtreecommitdiff
path: root/sql/sql_handler.cc
diff options
context:
space:
mode:
authorJon Olav Hauglid <jon.hauglid@sun.com>2010-02-25 18:08:12 +0100
committerJon Olav Hauglid <jon.hauglid@sun.com>2010-02-25 18:08:12 +0100
commit3eead1f0f18b2f36a14b845501cf72661b592fb4 (patch)
tree58cb63c46c37aca711bb8c360d3bd820839be9bc /sql/sql_handler.cc
parenta52ad97e67f703ab1a5ee9e49cf7a4cac9191534 (diff)
downloadmariadb-git-3eead1f0f18b2f36a14b845501cf72661b592fb4.tar.gz
Bug #51355 handler stmt cause assertion in
bool MDL_context::try_acquire_lock(MDL_request*) This assert was triggered in the following way: 1) HANDLER OPEN t1 from connection 1 2) DROP TABLE t1 from connection 2. This will block due to the metadata lock held by the open handler in connection 1. 3) DML statement (e.g. INSERT) from connection 1. This will close the table opened by the HANDLER in 1) and release its metadata lock. This is done due to the pending exclusive metadata lock from 2). 4) DROP TABLE t1 from connection 2 now completes and removes table t1. 5) HANDLER READ from connection 1. Since the handler table was closed in 3), the handler code will try to reopen the table. First a new metadata lock on t1 will be granted before the command fails since the table was removed in 4). 6) HANDLER READ from connection 1. This caused the assert. The reason for the assert was that the MDL_request's pointer to the lock ticket was not reset when the statement failed. HANDLER READ then tried to acquire a lock using the same MDL_request object, triggering the assert. This bug was only noticeable on debug builds and did not cause any problems on release builds. This patch fixes the problem by assuring that the pointer to the metadata lock ticket is reset when reopening of handler tables fails. Test case added to handler.inc
Diffstat (limited to 'sql/sql_handler.cc')
-rw-r--r--sql/sql_handler.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index 4a69b46ddb7..3afeb4164bd 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -311,7 +311,11 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
if (!reopen)
my_hash_delete(&thd->handler_tables_hash, (uchar*) hash_tables);
else
+ {
hash_tables->table= NULL;
+ /* Safety, cleanup the pointer to satisfy MDL assertions. */
+ hash_tables->mdl_request.ticket= NULL;
+ }
DBUG_PRINT("exit",("ERROR"));
DBUG_RETURN(TRUE);
}