diff options
author | Dmitry Lenev <dlenev@mysql.com> | 2010-08-06 15:29:37 +0400 |
---|---|---|
committer | Dmitry Lenev <dlenev@mysql.com> | 2010-08-06 15:29:37 +0400 |
commit | 8d0dc9b58bcb5f1cf13618eebe3fc6f60b8f2926 (patch) | |
tree | 23ceb8a5e2e80b264d2b9207503b7d451c924fb8 /sql/mdl.cc | |
parent | a91a5ee3bfab12437cd9b8ec3a41598c5e5fe47b (diff) | |
download | mariadb-git-8d0dc9b58bcb5f1cf13618eebe3fc6f60b8f2926.tar.gz |
Part of fix for bug#52044 "FLUSH TABLES WITH READ LOCK and
FLUSH TABLES <list> WITH READ LOCK are incompatible" to
be pushed as separate patch.
Replaced thread state name "Waiting for table", which was
used by threads waiting for a metadata lock or table flush,
with a set of names which better reflect types of resources
being waited for.
Also replaced "Table lock" thread state name, which was used
by threads waiting on thr_lock.c table level lock, with more
elaborate "Waiting for table level lock", to make it
more consistent with other thread state names.
Updated test cases and their results according to these
changes.
Fixed sys_vars.query_cache_wlock_invalidate_func test to not
to wait for timeout of wait_condition.inc script.
mysql-test/r/query_cache.result:
Added test coverage for query_cache_wlock_invalidate
behavior for implicitly locked tables.
mysql-test/suite/sys_vars/r/query_cache_wlock_invalidate_func.result:
Fixed sys_vars.query_cache_wlock_invalidate_func test to not
to wait for timeout of wait_condition.inc script. Reverted
changes to test which introduced timeout and replaced waiting
condition with a more appropriate one.
Test coverage for query_cache_wlock_invalidate behavior for
implicitly locked tables was added to query_cache.test.
mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_func.test:
Fixed sys_vars.query_cache_wlock_invalidate_func test to not
to wait for timeout of wait_condition.inc script. Reverted
changes to test which introduced timeout and replaced waiting
condition with a more appropriate one.
Test coverage for query_cache_wlock_invalidate behavior for
implicitly locked tables was added to query_cache.test.
mysql-test/t/query_cache.test:
Added test coverage for query_cache_wlock_invalidate
behavior for implicitly locked tables.
mysys/thr_lock.c:
Replaced "Table lock" thread state name, which was used by
threads waiting on thr_lock.c table level lock, with more
elaborate "Waiting for table level lock", to make it
consistent with thread state names which are used while
waiting for metadata locks and table flush.
sql/mdl.cc:
Replaced thread state name "Waiting for table", which was
used by threads waiting for a metadata lock or table flush,
with a set of names which better reflect types of resources
being waited for.
To implement this:
- Adjusted MDL_wait::timed_wait() to take thread state name
as parameter.
- Introduced method of MDL_key class which allows to get
thread state name to be used while waiting for resource
corresponding to the key and changed code to use it.
Added array translating namespaces to thread state names
as part of this change.
sql/mdl.h:
To implement this:
- Adjusted MDL_wait::timed_wait() to take thread state name
as parameter.
- Introduced method of MDL_key class which allows to get
thread state name to be used while waiting for resource
corresponding to the key and changed code to use it.
Added array translating namespaces to thread state names
as part of this change.
sql/sql_base.cc:
Replaced thread state name "Waiting for table", which was
used by threads waiting for table flush, with a more elaborate
"Waiting for table flush".
Diffstat (limited to 'sql/mdl.cc')
-rw-r--r-- | sql/mdl.cc | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/sql/mdl.cc b/sql/mdl.cc index ca66799baed..5b50b11647c 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -71,6 +71,21 @@ static void init_mdl_psi_keys(void) void notify_shared_lock(THD *thd, MDL_ticket *conflicting_ticket); +/** + Thread state names to be used in case when we have to wait on resource + belonging to certain namespace. +*/ + +const char *MDL_key::m_namespace_to_wait_state_name[NAMESPACE_END]= +{ + "Waiting for global metadata lock", + "Waiting for schema metadata lock", + "Waiting for table metadata lock", + "Waiting for stored function metadata lock", + "Waiting for stored procedure metadata lock", + NULL +}; + static bool mdl_initialized= 0; @@ -946,17 +961,18 @@ void MDL_wait::reset_status() Wait for the status to be assigned to this wait slot. @param abs_timeout Absolute time after which waiting should stop. - @param set_status_on_tiemout TRUE - If in case of timeout waiting - context should close the wait slot by - sending TIMEOUT to itself. - FALSE - Otherwise. + @param set_status_on_timeout TRUE - If in case of timeout waiting + context should close the wait slot by + sending TIMEOUT to itself. + FALSE - Otherwise. + @param wait_state_name Thread state name to be set for duration of wait. @returns Signal posted. */ MDL_wait::enum_wait_status MDL_wait::timed_wait(THD *thd, struct timespec *abs_timeout, - bool set_status_on_timeout) + bool set_status_on_timeout, const char *wait_state_name) { const char *old_msg; enum_wait_status result; @@ -965,7 +981,7 @@ MDL_wait::timed_wait(THD *thd, struct timespec *abs_timeout, mysql_mutex_lock(&m_LOCK_wait_status); old_msg= thd_enter_cond(thd, &m_COND_wait_status, &m_LOCK_wait_status, - "Waiting for table"); + wait_state_name); while (!m_wait_status && !thd_killed(thd) && wait_result != ETIMEDOUT && wait_result != ETIME) @@ -1746,7 +1762,8 @@ MDL_context::acquire_lock(MDL_request *mdl_request, ulong lock_wait_timeout) while (cmp_timespec(abs_shortwait, abs_timeout) <= 0) { /* abs_timeout is far away. Wait a short while and notify locks. */ - wait_status= m_wait.timed_wait(m_thd, &abs_shortwait, FALSE); + wait_status= m_wait.timed_wait(m_thd, &abs_shortwait, FALSE, + mdl_request->key.get_wait_state_name()); if (wait_status != MDL_wait::EMPTY) break; @@ -1757,10 +1774,12 @@ MDL_context::acquire_lock(MDL_request *mdl_request, ulong lock_wait_timeout) set_timespec(abs_shortwait, 1); } if (wait_status == MDL_wait::EMPTY) - wait_status= m_wait.timed_wait(m_thd, &abs_timeout, TRUE); + wait_status= m_wait.timed_wait(m_thd, &abs_timeout, TRUE, + mdl_request->key.get_wait_state_name()); } else - wait_status= m_wait.timed_wait(m_thd, &abs_timeout, TRUE); + wait_status= m_wait.timed_wait(m_thd, &abs_timeout, TRUE, + mdl_request->key.get_wait_state_name()); done_waiting_for(); |