summaryrefslogtreecommitdiff
path: root/sql/mdl.h
diff options
context:
space:
mode:
authorJon Olav Hauglid <jon.hauglid@oracle.com>2010-07-22 10:00:32 +0200
committerJon Olav Hauglid <jon.hauglid@oracle.com>2010-07-22 10:00:32 +0200
commitec002090b90a5da614582b24a82313995fa7e87b (patch)
tree5d8c042b8e4370ac27d8102138df6640dd6162ff /sql/mdl.h
parent7467ee7bc60cb393d2f9ef905da88a0f1d3ffe50 (diff)
downloadmariadb-git-ec002090b90a5da614582b24a82313995fa7e87b.tar.gz
Bug #55223 assert in Protocol::end_statement during CREATE DATABASE
The problem was that a statement could cause an assert if it was aborted by KILL QUERY while it waited on a metadata lock. This assert checks that a statement either sends OK or an error to the client. If the bug was triggered on release builds, it caused OK to be sent to the client instead of ER_QUERY_INTERRUPTED. The root cause of the problem was that there are two separate ways to tell if a statement is killed: thd->killed and mysys_var->abort. KILL QUERY causes both to be set, thd->killed before mysys_var->abort. Also, both values are reset at the end of statement execution. This means that it is possible for KILL QUERY to first set thd->killed, then have the killed statement reset both thd->killed and mysys_var->abort and finally have KILL QUERY set mysys_var->abort. This means that the connection with the killed statement will start executing the next statement with the two values out of sync - i.e. thd->killed not set but mysys_var->abort set. Since mysys_var->abort is used to check if a wait for a metadata lock should be aborted, the next statement would immediately abort any such waiting. When waiting is aborted, no OK message is sent and thd->killed is checked to see if ER_QUERY_INTERRUPTED should be sent to the client. But since the->killed had been reset, neither OK nor an error message was sent to the client. This then triggered the assert. This patch fixes the problem by changing the metadata lock waiting code to check thd->killed. No test case added as reproducing the assert is dependent on very exact timing of two (or more) threads. The patch has been checked using RQG and the grammar posted on the bug report.
Diffstat (limited to 'sql/mdl.h')
-rw-r--r--sql/mdl.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/sql/mdl.h b/sql/mdl.h
index 319c16cf6ce..c8acd69c0f1 100644
--- a/sql/mdl.h
+++ b/sql/mdl.h
@@ -721,10 +721,10 @@ void mdl_destroy();
extern bool mysql_notify_thread_having_shared_lock(THD *thd, THD *in_use,
bool needs_thr_lock_abort);
-extern "C" const char *set_thd_proc_info(void *thd_arg, const char *info,
- const char *calling_function,
- const char *calling_file,
- const unsigned int calling_line);
+extern "C" const char* thd_enter_cond(MYSQL_THD thd, mysql_cond_t *cond,
+ mysql_mutex_t *mutex, const char *msg);
+extern "C" void thd_exit_cond(MYSQL_THD thd, const char *old_msg);
+
#ifndef DBUG_OFF
extern mysql_mutex_t LOCK_open;
#endif