summaryrefslogtreecommitdiff
path: root/sql/lock.cc
diff options
context:
space:
mode:
authorJon Olav Hauglid <jon.hauglid@sun.com>2010-02-24 18:04:00 +0100
committerJon Olav Hauglid <jon.hauglid@sun.com>2010-02-24 18:04:00 +0100
commitdd42aab8406e70caec4f58435c0281cddc8ea2c0 (patch)
tree9d2e97b85337c7ffc2bf1d2a6643b34baf1acda8 /sql/lock.cc
parentb6e0f92f052a37568b984330b8cca8331c979a8d (diff)
downloadmariadb-git-dd42aab8406e70caec4f58435c0281cddc8ea2c0.tar.gz
Followup to Bug#45225 Locking: hang if drop table with no timeout
This patch prevents system threads and system table accesses from using user-specified values for "lock_wait_timeout". Instead all such accesses are done using the default value (1 year). This prevents background tasks (such as replication, events, accessing stored function definitions, logging, reading time-zone information, etc.) from failing in cases where the global value of "lock_wait_timeout" is set very low. The patch also simplifies the open tables API. Rather than adding another convenience function for opening and locking system tables, this patch removes most of the existing convenience functions for open_and_lock_tables_derived(). Before, open_and_lock_tables() was a convenience function that enforced derived tables handling, while open_and_lock_tables_derived() was the main function where derived tables handling was optional. Now, this convencience function is gone and the main function is renamed to open_and_lock_tables(). No test case added as it would have required the use of --sleep to check that system threads and system tables have a different timeout value from the user-specified "lock_wait_timeout" system variable.
Diffstat (limited to 'sql/lock.cc')
-rw-r--r--sql/lock.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/sql/lock.cc b/sql/lock.cc
index fa58e43f6bb..3ff131bb828 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -251,6 +251,7 @@ static void reset_lock_data_and_free(MYSQL_LOCK **mysql_lock)
MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK Ignore a global read lock
MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY Ignore SET GLOBAL READ_ONLY
MYSQL_LOCK_IGNORE_FLUSH Ignore a flush tables.
+ MYSQL_LOCK_IGNORE_TIMEOUT Use maximum timeout value.
@param need_reopen Out parameter, TRUE if some tables were altered
or deleted and should be reopened by caller.
@@ -277,6 +278,9 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
if (mysql_lock_tables_check(thd, tables, count, flags))
DBUG_RETURN (NULL);
+ ulong timeout= (flags & MYSQL_LOCK_IGNORE_TIMEOUT) ?
+ LONG_TIMEOUT : thd->variables.lock_wait_timeout;
+
for (;;)
{
if (! (sql_lock= get_lock_data(thd, tables, count, GET_LOCK_STORE_LOCKS,
@@ -336,8 +340,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
rc= thr_lock_errno_to_mysql[(int) thr_multi_lock(sql_lock->locks +
sql_lock->lock_count,
sql_lock->lock_count,
- thd->lock_id,
- thd->variables.lock_wait_timeout)];
+ thd->lock_id, timeout)];
if (rc > 1) /* a timeout or a deadlock */
{
if (sql_lock->table_count)