您现在的位置:主页 > 技术中心 > 数据库技术 > Mysql

改进MySQL的table_cache(2)

来源:未知 责任编辑:责任编辑 发表时间:2013-12-22 14:56 点击:

如果这是该query打开的第一个表:设置thd->version = refresh_version,这样,当我们打开剩余表的过程中,如果version发生了变化,则需要back off,关闭所有已经打开的并重新打开表

目前refresh_version只会被FLUSH TABLES命令改变

 

 if (thd->handler_tables)        

    mysql_ha_flush(thd);   //刷新(关闭并标记为re-open)所有需要reopen的表

 

 

查询table cache的过程:

 

 for (table= (TABLE*) hash_first(&open_cache, (uchar*) key, key_length,                  //基于同一个key来查找hash表

                                  &state);

       table && table->in_use ;

       table= (TABLE*) hash_next(&open_cache, (uchar*) key, key_length,

                                 &state))

{

    

 

**********************************

flush tables marked for flush.

 Normally, table->s->version contains the value of

      refresh_version from the moment when this table was

      (re-)opened and added to the cache.

      If since then we did (or just started) FLUSH TABLES

      statement, refresh_version has been increased.

      For "name-locked" TABLE instances, table->s->version is set

      to 0 (see lock_table_name for details).

      In case there is a pending FLUSH TABLES or a name lock, we

      need to back off and re-start opening tables.

      If we do not back off now, we may dead lock in case of lock

      order mismatch with some other thread:

      c1: name lock t1; -- sort of exclusive lock

      c2: open t2;      -- sort of shared lock

      c1: name lock t2; -- blocks

      c2: open t1; -- blocks

*********************************

 

             if (table->needs_reopen_or_name_lock())  //Is this instance of the table should be reopen or represents a name-lock?

发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片

推荐热点

  • mysql-mmm
  • mysqldump命令——MySQL数据库备份还原
  • Oracle数据导入MySQL的快捷工具:MySQL Migration Tool
  • 简简单单储存过程——循环一个select结果集
  • MySQL数据库十大优化技巧
  • Mysql安装笔记
  • Mysql主主复制架构配置
  • Mysql的Procedure 参数为NULL问题分析
  • MySQL Stmt预处理提高效率问题的小研究
?? - ?? - ÝřŝžľŘÝź - TAGąęÇŠ - RSSśŠÔÄ - ??
Copyright © 2004-2024 上海卓卓网络科技有限公司