diff options
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r-- | sql/sql_base.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 5c0b9f6a5a5..a9184d1cdf1 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -8884,7 +8884,6 @@ open_system_tables_for_read(THD *thd, TABLE_LIST *table_list, { Query_tables_list query_tables_list_backup; LEX *lex= thd->lex; - DBUG_ENTER("open_system_tables_for_read"); /* @@ -8898,9 +8897,15 @@ open_system_tables_for_read(THD *thd, TABLE_LIST *table_list, thd->reset_n_backup_open_tables_state(backup); thd->lex->sql_command= SQLCOM_SELECT; + /* + Only use MYSQL_LOCK_IGNORE_TIMEOUT for tables opened for read. + This is to ensure that lock_wait_timeout is honored when trying + to update stats tables. + */ if (open_and_lock_tables(thd, table_list, FALSE, - MYSQL_OPEN_IGNORE_FLUSH | - MYSQL_LOCK_IGNORE_TIMEOUT)) + (MYSQL_OPEN_IGNORE_FLUSH | + (table_list->lock_type < TL_WRITE_ALLOW_WRITE ? + MYSQL_LOCK_IGNORE_TIMEOUT : 0)))) { lex->restore_backup_query_tables_list(&query_tables_list_backup); thd->restore_backup_open_tables_state(backup); |