summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
diff options
context:
space:
mode:
authorKonstantin Osipov <kostja@sun.com>2009-12-01 18:20:43 +0300
committerKonstantin Osipov <kostja@sun.com>2009-12-01 18:20:43 +0300
commitf7ba9dafd5f92863ffd9a0b3ebee7147d73bbb21 (patch)
tree861487d2be89b022dcce6bfc3f0fae919ee697e6 /sql/sql_base.cc
parentdb3f97c3fb2f0e39d56fc813877ff9d38b61af2f (diff)
downloadmariadb-git-f7ba9dafd5f92863ffd9a0b3ebee7147d73bbb21.tar.gz
Backport of:
------------------------------------------------------------ revno: 2630.9.2 committer: Dmitry Lenev <dlenev@mysql.com> branch nick: mysql-6.0-3726-w3 timestamp: Tue 2008-06-10 18:01:56 +0400 message: WL#3726 "DDL locking for all metadata objects". After review fixes in progress. sql/mdl.cc: Changed mdl_acquire_shared_lock() signature to accept MDL_CONTEXT as one of arguments as described in specification. sql/mdl.h: Changed mdl_acquire_shared_lock() signature to accept MDL_CONTEXT as one of arguments as described in specification. sql/sql_base.cc: Changed mdl_acquire_shared_lock() signature to accept MDL_CONTEXT as one of arguments as described in specification. Renamed handle_failed_open_table_attempt() to recover_from_failed_open_table_attempt() as suggested by review. Added comment clarifying why we need to check TABLE::db_stat while looking at TABLE instances open by other threads. sql/sql_show.cc: Changed mdl_acquire_shared_lock() signature to accept MDL_CONTEXT as one of arguments as described in specification.
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r--sql/sql_base.cc23
1 files changed, 16 insertions, 7 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 8665cebc4ed..633184cde79 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2837,7 +2837,7 @@ bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
if (flags & MYSQL_LOCK_IGNORE_FLUSH)
mdl_set_lock_type(mdl_lock_data, MDL_SHARED_HIGH_PRIO);
- if (mdl_acquire_shared_lock(mdl_lock_data, &retry))
+ if (mdl_acquire_shared_lock(&thd->mdl_context, mdl_lock_data, &retry))
{
if (retry)
*action= OT_BACK_OFF_AND_RETRY;
@@ -4044,18 +4044,21 @@ end_with_lock_open:
/**
- Handle failed attempt ot open table by performing requested action.
+ Recover from failed attempt ot open table by performing requested action.
@param thd Thread context
@param table Table list element for table that caused problem
@param action Type of action requested by failed open_table() call
+ @pre This function should be called only with "action" != OT_NO_ACTION.
+
@retval FALSE - Success. One should try to open tables once again.
@retval TRUE - Error
*/
-static bool handle_failed_open_table_attempt(THD *thd, TABLE_LIST *table,
- enum_open_table_action action)
+static bool
+recover_from_failed_open_table_attempt(THD *thd, TABLE_LIST *table,
+ enum_open_table_action action)
{
bool result= FALSE;
@@ -4678,7 +4681,7 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags)
TABLE_LIST element. Altough currently this assumption is valid
it may change in future.
*/
- if (handle_failed_open_table_attempt(thd, tables, action))
+ if (recover_from_failed_open_table_attempt(thd, tables, action))
{
result= -1;
goto err;
@@ -4997,7 +5000,7 @@ retry:
might have been acquired successfully.
*/
close_thread_tables(thd, (action == OT_BACK_OFF_AND_RETRY));
- if (handle_failed_open_table_attempt(thd, table_list, action))
+ if (recover_from_failed_open_table_attempt(thd, table_list, action))
break;
}
@@ -8530,7 +8533,13 @@ bool notify_thread_having_shared_lock(THD *thd, THD *in_use)
thd_table ;
thd_table= thd_table->next)
{
- /* TODO With new MDL check for db_stat is probably a legacy */
+ /*
+ Check for TABLE::db_stat is needed since in some places we call
+ handler::close() for table instance (and set TABLE::db_stat to 0)
+ and do not remove such instances from the THD::open_tables
+ for some time, during which other thread can see those instances
+ (e.g. see partitioning code).
+ */
if (thd_table->db_stat)
signalled|= mysql_lock_abort_for_thread(thd, thd_table);
}