diff options
author | Konstantin Osipov <kostja@sun.com> | 2010-06-10 15:31:19 +0400 |
---|---|---|
committer | Konstantin Osipov <kostja@sun.com> | 2010-06-10 15:31:19 +0400 |
commit | 47b9f64c534f51af037d1bad7b27dfa9a1d1c284 (patch) | |
tree | 72b4e0a98e981e6980b8bbc7503413b8863472ab /sql/sql_table.cc | |
parent | 75d7bb91a3013cc0fa99003c638f154930966b12 (diff) | |
download | mariadb-git-47b9f64c534f51af037d1bad7b27dfa9a1d1c284.tar.gz |
A pre-requisite patch for WL#5419 "LOCK_open scalability:
make tdc_refresh_version an atomic counter".
To avoid orphaned TABLE_SHARE objects left in the
cache, make sure that wherever we set table->s->version
we take care of removing all unused table share objects
from the table cache.
Always set table->s->version under LOCK_open, to make sure
that no other connection sees an old value of the
version and adds the table to unused_tables list.
Add an assert to table_def_unuse_table() that we never
'unuse' a talbe of a share that has an old version.
With this patch, only three places are left in the code
that manipulate with table->s->version:
- tdc_remove_table(). In most cases we have an X mdl lock
in tdc_remove_table(), the two remaining cases when we
don't are 'FLUSH TABLE' and mysql_admin_table().
- sql_view.cc - a crude hack that needs a separate fix
- initial assignment from refresh_version in table.cc.
sql/sql_base.cc:
Add an assert.
Don't manipulate with table->s->version in auto-repair, auto-discover.
Use tdc_remove_table() in auto_repair_table() and drop_open_table().
sql/sql_table.cc:
Remove dead code from mysql_admin_table().
Manipulate with table->s->version through the TDC API.
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 843fb5b35d2..3e9d26bd253 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -85,19 +85,6 @@ mysql_prepare_alter_table(THD *thd, TABLE *table, HA_CREATE_INFO *create_info, Alter_info *alter_info); -#ifndef DBUG_OFF - -/* Wait until we get a 'mysql_kill' signal */ - -static void wait_for_kill_signal(THD *thd) -{ - while (thd->killed == 0) - sleep(1); - // Reset signal and continue as if nothing happend - thd->killed= THD::NOT_KILLED; -} -#endif - /** @brief Helper function for explain_filename @@ -4877,18 +4864,30 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, /* purecov: end */ } - /* Close all instances of the table to allow repair to rename files */ - if (lock_type == TL_WRITE && table->table->s->version) + /* + Close all instances of the table to allow MyISAM "repair" + to rename files. + @todo: This code does not close all instances of the table. + It only closes instances in other connections, but if this + connection has LOCK TABLE t1 a READ, t1 b WRITE, + both t1 instances will be kept open. + There is no need to execute this branch for InnoDB, which does + repair by recreate. There is no need to do it for OPTIMIZE, + which doesn't move files around. + Hence, this code should be moved to prepare_for_repair(), + and executed only for MyISAM engine. + */ + if (lock_type == TL_WRITE && !table->table->s->tmp_table) { if (wait_while_table_is_used(thd, table->table, HA_EXTRA_PREPARE_FOR_RENAME)) goto err; - DBUG_EXECUTE_IF("wait_in_mysql_admin_table", - wait_for_kill_signal(thd); - if (thd->killed) - goto err;); /* Flush entries in the query cache involving this table. */ query_cache_invalidate3(thd, table->table, 0); + /* + XXX: hack: switch off open_for_modify to skip the + flush that is made later in the execution flow. + */ open_for_modify= 0; } @@ -5148,20 +5147,21 @@ send_result_message: } if (table->table) { - if (fatal_error) - table->table->s->version=0; // Force close of table - else if (open_for_modify) + if (table->table->s->tmp_table) { - if (table->table->s->tmp_table) + if (open_for_modify) table->table->file->info(HA_STATUS_CONST); - else - { - TABLE_LIST *save_next_global= table->next_global; - table->next_global= 0; - close_cached_tables(thd, table, FALSE, FALSE); - table->next_global= save_next_global; - } - /* May be something modified consequently we have to invalidate cache */ + } + else if (open_for_modify || fatal_error) + { + mysql_mutex_lock(&LOCK_open); + tdc_remove_table(thd, TDC_RT_REMOVE_UNUSED, + table->db, table->table_name); + mysql_mutex_unlock(&LOCK_open); + /* + May be something modified. Consequently, we have to + invalidate the query cache. + */ query_cache_invalidate3(thd, table->table, 0); } } |