• Konstantin Osipov's avatar
    A new implementation for the TABLE_SHARE cache in MDL · 429454f7
    Konstantin Osipov authored
    subsystem. Fix a number of caveates that the previous
    implementation suffered from, including unprotected
    access to shared data and lax resource accounting
    (share->ref_count) that could lead to deadlocks.
    
    The new implementation still suffers from a number
    of potential deadlocks in some edge cases, and this is 
    still not enabled by default. Especially since performance
    testing has shown that it gives only marginable (not even 
    exceeding measuring accuracy) improvements.
    
    @todo: 
    - Remove calls to close_cached_tables() with REFRESH_FAST,
    and have_lock, because they break the MDL cache. 
    - rework FLUSH TABLES <list> to not use close_cached_tables()
    - make sure that whenever we set TABLE_SHARE::version to
    0 we free MDL cache references to it.
    
    
    sql/mdl.cc:
      We may cache references to TABLE_SHARE objects in 
      MDL_lock objects for tables. Create a separate
      MDL_lock class to represent a table.
    sql/mdl.h:
      Adjust the MDL caching API to avoid races.
    sql/sql_base.cc:
      Move all caching functionality close together.
      Implement a solution for deadlocks caused by 
      close_cached_tables() when MDL cache is enabled (incomplete).
    sql/sql_yacc.yy:
      Adjust FLUSH rule to do the necessary initialization of
      TABLE_LIST elements used in for FLUSH TABLES <list>, and thus
      work OK with flush_mdl_cache() function.
    429454f7
sql_yacc.yy 427 KB