Commit edddfa0e authored by Konstantin Osipov's avatar Konstantin Osipov

Backport of:

------------------------------------------------------------
revno: 2630.4.33
committer: Dmitry Lenev <dlenev@mysql.com>
branch nick: mysql-6.0-3726-w2
timestamp: Fri 2008-06-20 17:11:20 +0400
message:
  WL#3726 "DDL locking for all metadata objects".

  After-review fixes in progress.

  Minimized dependency of mdl.cc on other modules (particularly
  made it independant of mysql_priv.h) in order to be able
  write unit tests for metadata locking subsystem.
parent 0a49fd92
...@@ -141,7 +141,7 @@ static Uint64 *p_latest_trans_gci= 0; ...@@ -141,7 +141,7 @@ static Uint64 *p_latest_trans_gci= 0;
static TABLE *ndb_binlog_index= 0; static TABLE *ndb_binlog_index= 0;
static TABLE_LIST binlog_tables; static TABLE_LIST binlog_tables;
static MDL_LOCK_DATA binlog_mdl_lock_data; static MDL_LOCK_DATA binlog_mdl_lock_data;
static char binlog_mdlkey[MAX_DBKEY_LENGTH]; static char binlog_mdlkey[MAX_MDLKEY_LENGTH];
/* /*
Helper functions Helper functions
......
...@@ -8074,7 +8074,7 @@ int Table_map_log_event::do_apply_event(Relay_log_info const *rli) ...@@ -8074,7 +8074,7 @@ int Table_map_log_event::do_apply_event(Relay_log_info const *rli)
&db_mem, (uint) NAME_LEN + 1, &db_mem, (uint) NAME_LEN + 1,
&tname_mem, (uint) NAME_LEN + 1, &tname_mem, (uint) NAME_LEN + 1,
&mdl_lock_data, sizeof(MDL_LOCK_DATA), &mdl_lock_data, sizeof(MDL_LOCK_DATA),
&mdlkey, MAX_DBKEY_LENGTH, &mdlkey, MAX_MDLKEY_LENGTH,
NullS))) NullS)))
DBUG_RETURN(HA_ERR_OUT_OF_MEM); DBUG_RETURN(HA_ERR_OUT_OF_MEM);
......
This diff is collapsed.
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "sql_plist.h" #include "sql_plist.h"
#include <my_sys.h> #include <my_sys.h>
#include <m_string.h> #include <m_string.h>
#include <mysql_com.h>
class THD; class THD;
...@@ -148,6 +149,9 @@ void mdl_context_backup_and_reset(MDL_CONTEXT *ctx, MDL_CONTEXT *backup); ...@@ -148,6 +149,9 @@ void mdl_context_backup_and_reset(MDL_CONTEXT *ctx, MDL_CONTEXT *backup);
void mdl_context_restore(MDL_CONTEXT *ctx, MDL_CONTEXT *backup); void mdl_context_restore(MDL_CONTEXT *ctx, MDL_CONTEXT *backup);
void mdl_context_merge(MDL_CONTEXT *target, MDL_CONTEXT *source); void mdl_context_merge(MDL_CONTEXT *target, MDL_CONTEXT *source);
/** Maximal length of key for metadata locking subsystem. */
#define MAX_MDLKEY_LENGTH (4 + NAME_LEN + 1 + NAME_LEN + 1)
void mdl_init_lock(MDL_LOCK_DATA *lock_data, char *key, int type, void mdl_init_lock(MDL_LOCK_DATA *lock_data, char *key, int type,
const char *db, const char *name); const char *db, const char *name);
MDL_LOCK_DATA *mdl_alloc_lock(int type, const char *db, const char *name, MDL_LOCK_DATA *mdl_alloc_lock(int type, const char *db, const char *name,
...@@ -237,4 +241,19 @@ void* mdl_get_cached_object(MDL_LOCK_DATA *lock_data); ...@@ -237,4 +241,19 @@ void* mdl_get_cached_object(MDL_LOCK_DATA *lock_data);
void mdl_set_cached_object(MDL_LOCK_DATA *lock_data, void *cached_object, void mdl_set_cached_object(MDL_LOCK_DATA *lock_data, void *cached_object,
mdl_cached_object_release_hook release_hook); mdl_cached_object_release_hook release_hook);
/*
Functions in the server's kernel used by metadata locking subsystem.
*/
extern bool mysql_notify_thread_having_shared_lock(THD *thd, THD *in_use);
extern void mysql_ha_flush(THD *thd);
extern "C" const char *set_thd_proc_info(THD *thd, const char *info,
const char *calling_function,
const char *calling_file,
const unsigned int calling_line);
#ifndef DBUG_OFF
extern pthread_mutex_t LOCK_open;
#endif
#endif #endif
...@@ -1534,8 +1534,6 @@ char *generate_partition_syntax(partition_info *part_info, ...@@ -1534,8 +1534,6 @@ char *generate_partition_syntax(partition_info *part_info,
Alter_info *alter_info); Alter_info *alter_info);
#endif #endif
bool notify_thread_having_shared_lock(THD *thd, THD *in_use);
enum enum_tdc_remove_table_type {TDC_RT_REMOVE_ALL, TDC_RT_REMOVE_NOT_OWN, enum enum_tdc_remove_table_type {TDC_RT_REMOVE_ALL, TDC_RT_REMOVE_NOT_OWN,
TDC_RT_REMOVE_UNUSED}; TDC_RT_REMOVE_UNUSED};
void tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type, void tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type,
......
...@@ -1275,7 +1275,7 @@ close_all_tables_for_name(THD *thd, TABLE_SHARE *share, ...@@ -1275,7 +1275,7 @@ close_all_tables_for_name(THD *thd, TABLE_SHARE *share,
/* /*
We need to hold LOCK_open while changing the open_tables We need to hold LOCK_open while changing the open_tables
list, since another thread may work on it. list, since another thread may work on it.
@sa notify_thread_having_shared_lock() @sa mysql_notify_thread_having_shared_lock()
*/ */
pthread_mutex_lock(&LOCK_open); pthread_mutex_lock(&LOCK_open);
...@@ -1455,7 +1455,7 @@ void close_thread_tables(THD *thd, ...@@ -1455,7 +1455,7 @@ void close_thread_tables(THD *thd,
/* /*
Note that we need to hold LOCK_open while changing the Note that we need to hold LOCK_open while changing the
open_tables list. Another thread may work on it. open_tables list. Another thread may work on it.
(See: notify_thread_having_shared_lock()) (See: mysql_notify_thread_having_shared_lock())
Closing a MERGE child before the parent would be fatal if the Closing a MERGE child before the parent would be fatal if the
other thread tries to abort the MERGE lock in between. other thread tries to abort the MERGE lock in between.
*/ */
...@@ -7956,7 +7956,7 @@ void flush_tables() ...@@ -7956,7 +7956,7 @@ void flush_tables()
rest of the server is broken. rest of the server is broken.
*/ */
bool notify_thread_having_shared_lock(THD *thd, THD *in_use) bool mysql_notify_thread_having_shared_lock(THD *thd, THD *in_use)
{ {
bool signalled= FALSE; bool signalled= FALSE;
if ((in_use->system_thread & SYSTEM_THREAD_DELAYED_INSERT) && if ((in_use->system_thread & SYSTEM_THREAD_DELAYED_INSERT) &&
...@@ -8501,7 +8501,7 @@ void close_performance_schema_table(THD *thd, Open_tables_state *backup) ...@@ -8501,7 +8501,7 @@ void close_performance_schema_table(THD *thd, Open_tables_state *backup)
/* /*
Note that we need to hold LOCK_open while changing the Note that we need to hold LOCK_open while changing the
open_tables list. Another thread may work on it. open_tables list. Another thread may work on it.
(See: notify_thread_having_shared_lock()) (See: mysql_notify_thread_having_shared_lock())
Closing a MERGE child before the parent would be fatal if the Closing a MERGE child before the parent would be fatal if the
other thread tries to abort the MERGE lock in between. other thread tries to abort the MERGE lock in between.
*/ */
......
...@@ -247,7 +247,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen) ...@@ -247,7 +247,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
&name, (uint) namelen, &name, (uint) namelen,
&alias, (uint) aliaslen, &alias, (uint) aliaslen,
&mdl_lock_data, sizeof(MDL_LOCK_DATA), &mdl_lock_data, sizeof(MDL_LOCK_DATA),
&mdlkey, MAX_DBKEY_LENGTH, &mdlkey, MAX_MDLKEY_LENGTH,
NullS))) NullS)))
{ {
DBUG_PRINT("exit",("ERROR")); DBUG_PRINT("exit",("ERROR"));
......
...@@ -3084,7 +3084,7 @@ uint get_table_open_method(TABLE_LIST *tables, ...@@ -3084,7 +3084,7 @@ uint get_table_open_method(TABLE_LIST *tables,
@param mdlkey Pointer to the buffer for key for the lock request @param mdlkey Pointer to the buffer for key for the lock request
(should be at least strlen(db) + strlen(name) + 2 (should be at least strlen(db) + strlen(name) + 2
bytes, or, if the lengths are not known, bytes, or, if the lengths are not known,
MAX_DBNAME_LENGTH) MAX_MDLKEY_LENGTH)
@param table Table list element for the table @param table Table list element for the table
@note This is an auxiliary function to be used in cases when we want to @note This is an auxiliary function to be used in cases when we want to
...@@ -3157,7 +3157,7 @@ static int fill_schema_table_from_frm(THD *thd,TABLE *table, ...@@ -3157,7 +3157,7 @@ static int fill_schema_table_from_frm(THD *thd,TABLE *table,
uint key_length; uint key_length;
char db_name_buff[NAME_LEN + 1], table_name_buff[NAME_LEN + 1]; char db_name_buff[NAME_LEN + 1], table_name_buff[NAME_LEN + 1];
MDL_LOCK_DATA mdl_lock_data; MDL_LOCK_DATA mdl_lock_data;
char mdlkey[MAX_DBKEY_LENGTH]; char mdlkey[MAX_MDLKEY_LENGTH];
bzero((char*) &table_list, sizeof(TABLE_LIST)); bzero((char*) &table_list, sizeof(TABLE_LIST));
bzero((char*) &tbl, sizeof(TABLE)); bzero((char*) &tbl, sizeof(TABLE));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment