Commit dcf1fd73 authored by unknown's avatar unknown

Don't save & restore time fields from thd when it's not needed.

Added back setting of 'some_tables_deleted' to not cause deadlocks in mysql_lock_table()


BitKeeper/etc/ignore:
  added tests/bug25714
sql/lock.cc:
  Added comment
sql/log.cc:
  Don't save & restore time fields from thd when it's not needed.
  Fix that we properly detect if open table failed
sql/sql_base.cc:
  Added back setting of 'some_tables_deleted' to not cause deadlocks in
  mysql_lock_table()
parent 926664fe
...@@ -2996,3 +2996,4 @@ win/vs8cache.txt ...@@ -2996,3 +2996,4 @@ win/vs8cache.txt
zlib/*.ds? zlib/*.ds?
zlib/*.vcproj zlib/*.vcproj
support-files/mysqld_multi.server support-files/mysqld_multi.server
tests/bug25714
...@@ -290,6 +290,10 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, ...@@ -290,6 +290,10 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
} }
else if (!thd->some_tables_deleted || (flags & MYSQL_LOCK_IGNORE_FLUSH)) else if (!thd->some_tables_deleted || (flags & MYSQL_LOCK_IGNORE_FLUSH))
{ {
/*
Thread was killed or lock aborted. Let upper level close all
used tables and retry or give error.
*/
thd->locked=0; thd->locked=0;
break; break;
} }
......
...@@ -323,20 +323,11 @@ bool Log_to_csv_event_handler:: ...@@ -323,20 +323,11 @@ bool Log_to_csv_event_handler::
Field_timestamp *field0; Field_timestamp *field0;
ulonglong save_thd_options; ulonglong save_thd_options;
bool save_query_start_used; bool save_query_start_used;
time_t save_start_time;
time_t save_time_after_lock;
time_t save_user_time;
bool save_time_zone_used;
save_query_start_used= thd->query_start_used; // Because of field->set_time()
save_thd_options= thd->options; save_thd_options= thd->options;
thd->options&= ~OPTION_BIN_LOG; thd->options&= ~OPTION_BIN_LOG;
save_query_start_used= thd->query_start_used;
save_start_time= thd->start_time;
save_time_after_lock= thd->time_after_lock;
save_user_time= thd->user_time;
save_time_zone_used= thd->time_zone_used;
bzero(& table_list, sizeof(TABLE_LIST)); bzero(& table_list, sizeof(TABLE_LIST));
table_list.alias= table_list.table_name= GENERAL_LOG_NAME.str; table_list.alias= table_list.table_name= GENERAL_LOG_NAME.str;
table_list.table_name_length= GENERAL_LOG_NAME.length; table_list.table_name_length= GENERAL_LOG_NAME.length;
...@@ -346,12 +337,13 @@ bool Log_to_csv_event_handler:: ...@@ -346,12 +337,13 @@ bool Log_to_csv_event_handler::
table_list.db= MYSQL_SCHEMA_NAME.str; table_list.db= MYSQL_SCHEMA_NAME.str;
table_list.db_length= MYSQL_SCHEMA_NAME.length; table_list.db_length= MYSQL_SCHEMA_NAME.length;
table= open_performance_schema_table(thd, & table_list, if (!(table= open_performance_schema_table(thd, & table_list,
& open_tables_backup); & open_tables_backup)))
goto err;
need_close= TRUE; need_close= TRUE;
if (!table || if (table->file->extra(HA_EXTRA_MARK_AS_LOG_TABLE) ||
table->file->extra(HA_EXTRA_MARK_AS_LOG_TABLE) ||
table->file->ha_rnd_init(0)) table->file->ha_rnd_init(0))
goto err; goto err;
...@@ -434,12 +426,7 @@ err: ...@@ -434,12 +426,7 @@ err:
close_performance_schema_table(thd, & open_tables_backup); close_performance_schema_table(thd, & open_tables_backup);
thd->options= save_thd_options; thd->options= save_thd_options;
thd->query_start_used= save_query_start_used; thd->query_start_used= save_query_start_used;
thd->start_time= save_start_time;
thd->time_after_lock= save_time_after_lock;
thd->user_time= save_user_time;
thd->time_zone_used= save_time_zone_used;
return result; return result;
} }
...@@ -485,11 +472,6 @@ bool Log_to_csv_event_handler:: ...@@ -485,11 +472,6 @@ bool Log_to_csv_event_handler::
bool need_close= FALSE; bool need_close= FALSE;
bool need_rnd_end= FALSE; bool need_rnd_end= FALSE;
Open_tables_state open_tables_backup; Open_tables_state open_tables_backup;
bool save_query_start_used;
time_t save_start_time;
time_t save_time_after_lock;
time_t save_user_time;
bool save_time_zone_used;
CHARSET_INFO *client_cs= thd->variables.character_set_client; CHARSET_INFO *client_cs= thd->variables.character_set_client;
DBUG_ENTER("Log_to_csv_event_handler::log_slow"); DBUG_ENTER("Log_to_csv_event_handler::log_slow");
...@@ -502,18 +484,13 @@ bool Log_to_csv_event_handler:: ...@@ -502,18 +484,13 @@ bool Log_to_csv_event_handler::
table_list.db= MYSQL_SCHEMA_NAME.str; table_list.db= MYSQL_SCHEMA_NAME.str;
table_list.db_length= MYSQL_SCHEMA_NAME.length; table_list.db_length= MYSQL_SCHEMA_NAME.length;
save_query_start_used= thd->query_start_used; if (!(table= open_performance_schema_table(thd, & table_list,
save_start_time= thd->start_time; & open_tables_backup)))
save_time_after_lock= thd->time_after_lock; goto err;
save_user_time= thd->user_time;
save_time_zone_used= thd->time_zone_used;
table= open_performance_schema_table(thd, & table_list,
& open_tables_backup);
need_close= TRUE; need_close= TRUE;
if (!table || if (table->file->extra(HA_EXTRA_MARK_AS_LOG_TABLE) ||
table->file->extra(HA_EXTRA_MARK_AS_LOG_TABLE) ||
table->file->ha_rnd_init(0)) table->file->ha_rnd_init(0))
goto err; goto err;
...@@ -635,11 +612,6 @@ err: ...@@ -635,11 +612,6 @@ err:
if (need_close) if (need_close)
close_performance_schema_table(thd, & open_tables_backup); close_performance_schema_table(thd, & open_tables_backup);
thd->query_start_used= save_query_start_used;
thd->start_time= save_start_time;
thd->time_after_lock= save_time_after_lock;
thd->user_time= save_user_time;
thd->time_zone_used= save_time_zone_used;
DBUG_RETURN(result); DBUG_RETURN(result);
} }
......
...@@ -7198,6 +7198,12 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name, ...@@ -7198,6 +7198,12 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
else if (in_use != thd) else if (in_use != thd)
{ {
DBUG_PRINT("info", ("Table was in use by other thread")); DBUG_PRINT("info", ("Table was in use by other thread"));
/*
Mark that table is going to be deleted from cache. This will
force threads that are in mysql_lock_tables() (but not yet
in thr_multi_lock()) to abort it's locks, close all tables and retry
*/
in_use->some_tables_deleted= 1;
if (table->is_name_opened()) if (table->is_name_opened())
{ {
DBUG_PRINT("info", ("Found another active instance of the table")); DBUG_PRINT("info", ("Found another active instance of the 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