diff options
author | Dmitry Lenev <dlenev@mysql.com> | 2010-07-27 17:34:58 +0400 |
---|---|---|
committer | Dmitry Lenev <dlenev@mysql.com> | 2010-07-27 17:34:58 +0400 |
commit | 5fff906edd3d7a5d999cec5403f009f33f8dfb81 (patch) | |
tree | bef62913efddc244d466f7ff730bcc4205357491 /sql/sql_base.h | |
parent | ec2c3bf2c1c27e4401c767a6cdcb3172453ff42c (diff) | |
download | mariadb-git-5fff906edd3d7a5d999cec5403f009f33f8dfb81.tar.gz |
Fix for bug #52044 "FLUSH TABLES WITH READ LOCK and FLUSH
TABLES <list> WITH READ LOCK are incompatible".
The problem was that FLUSH TABLES <list> WITH READ LOCK
which was issued when other connection has acquired global
read lock using FLUSH TABLES WITH READ LOCK was blocked
and has to wait until global read lock is released.
This issue stemmed from the fact that FLUSH TABLES <list>
WITH READ LOCK implementation has acquired X metadata locks
on tables to be flushed. Since these locks required acquiring
of global IX lock this statement was incompatible with global
read lock.
This patch addresses problem by using SNW metadata type of
lock for tables to be flushed by FLUSH TABLES <list> WITH
READ LOCK. It is OK to acquire them without global IX lock
as long as we won't try to upgrade those locks. Since SNW
locks allow concurrent statements using same table FLUSH
TABLE <list> WITH READ LOCK now has to wait until old
versions of tables to be flushed go away after acquiring
metadata locks. Since such waiting can lead to deadlock
MDL deadlock detector was extended to take into account
waits for flush and resolve such deadlocks.
As a bonus code in open_tables() which was responsible for
waiting old versions of tables to go away was refactored.
Now when we encounter old version of table in open_table()
we don't back-off and wait for all old version to go away,
but instead wait for this particular table to be flushed.
Such approach supported by deadlock detection should reduce
number of scenarios in which FLUSH TABLES aborts concurrent
multi-statement transactions.
Note that active FLUSH TABLES <list> WITH READ LOCK still
blocks concurrent FLUSH TABLES WITH READ LOCK statement
as the former keeps tables open and thus prevents the
latter statement from doing flush.
Diffstat (limited to 'sql/sql_base.h')
-rw-r--r-- | sql/sql_base.h | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/sql/sql_base.h b/sql/sql_base.h index b912f80d44f..7d13b69e063 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -250,7 +250,7 @@ TABLE *open_performance_schema_table(THD *thd, TABLE_LIST *one_table, void close_performance_schema_table(THD *thd, Open_tables_state *backup); bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock, - bool wait_for_refresh); + bool wait_for_refresh, ulong timeout); bool close_cached_connection_tables(THD *thd, bool wait_for_refresh, LEX_STRING *connect_string, bool have_lock = FALSE); @@ -454,8 +454,8 @@ public: enum enum_open_table_action { OT_NO_ACTION= 0, - OT_MDL_CONFLICT, - OT_WAIT_TDC, + OT_CONFLICT, + OT_REOPEN_TABLES, OT_DISCOVER, OT_REPAIR }; @@ -465,9 +465,6 @@ public: bool request_backoff_action(enum_open_table_action action_arg, TABLE_LIST *table); - void add_request(MDL_request *request) - { m_mdl_requests.push_front(request); } - bool can_recover_from_failed_open() const { return m_action != OT_NO_ACTION; } @@ -489,8 +486,6 @@ public: uint get_flags() const { return m_flags; } private: - /** List of requests for all locks taken so far. Used for waiting on locks. */ - MDL_request_list m_mdl_requests; /** For OT_DISCOVER and OT_REPAIR actions, the table list element for the table which definition should be re-discovered or which |