• Konstantin Osipov's avatar
    A pre-requisite patch for WL#5419 "LOCK_open scalability: · 47b9f64c
    Konstantin Osipov authored
    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.
    47b9f64c
sql_table.cc 258 KB