Skip to content
  • Gopal Shankar's avatar
    20474967
    Bug#21376265 - ENHANCEMENT: ACQUIRE MDL LOCKS ON ALL TABLESPACE · 20474967
    Gopal Shankar authored
                   REFERRED BY A STATEMENT
    
    Description:
    
    WL#7957 lists following as a future enhancement.
    ...
    F-10
    When defining partitioned tables, assigning explicit tablespace
    names is not supported for the individual partitions. However,
    with the implementation of SE native partitioning (e.g. WL#6035
    for InnoDB), this will mean that the various DDL statements need
    to take more than one tablespace into account.  Thus, in the
    future, this will affect F-3 above, but for now, in the context
    of this worklog, this is deferred.
    ...
    
    WL#6035 is pushed and we support more than one tablespace
    (explicit tablespace per partition) in various DDL statements,
    and the problem is we do not take MDL locks on all tablespaces in
    use.
    
    Solution:
    Acquire IX MDL lock on tablespace names used by partition and
    sub-partition definitions along with tablespace name used by
    table. We do that in following cases,
    
    1. Lock only the target tablespace name and tablespace
       names that are used by partitions (e.g. CREATE TABLE
       explicitly specifying the tablespace names).
    
    2. Lock only the existing tablespace name and tablespace
       names that are used by partitions (e.g. ALTER TABLE t
       ADD COLUMN ... where t is defined in some tablespace s.
    
    3. Lock both the target and the existing tablespace names
       along with tablespace names used by partitions. (e.g.
       ALTER TABLE t TABLESPACE s2, where t is defined in
       some tablespace s)
    
    4. Lock on tablespace names used by new partitions that are
       added by following command,
    
        => ALTER TABLE <table_name>
             ADD PARTITION
               (PARTITION .. TABLESPACE <tablespace_name>);
    
       Currently lock_table_names() does try and lock partition
       tablespace names that are part of thd->work_part_info as
       Phase 4$ invoking check_and_lock_tablespace_names().
       During ALTER TABLE we currently set thd->work_part_info
       with new partition information bit late after the
       lock_table_names() is done. The fix is to make new
       partition information available in thd->work_part_info
       before we request MDL locks.
    
    5. Lock on tablespace names for the source table and source table
       partitions, in case of CREATE TABLE LIKE.
    
    Tablespace names used by partitions are retrieved by parsing
    the partition expression stored in .FRM. This applies even for
    for NDB tables with partitions before mysql version 50120.
    20474967
    Bug#21376265 - ENHANCEMENT: ACQUIRE MDL LOCKS ON ALL TABLESPACE
    Gopal Shankar authored
                   REFERRED BY A STATEMENT
    
    Description:
    
    WL#7957 lists following as a future enhancement.
    ...
    F-10
    When defining partitioned tables, assigning explicit tablespace
    names is not supported for the individual partitions. However,
    with the implementation of SE native partitioning (e.g. WL#6035
    for InnoDB), this will mean that the various DDL statements need
    to take more than one tablespace into account.  Thus, in the
    future, this will affect F-3 above, but for now, in the context
    of this worklog, this is deferred.
    ...
    
    WL#6035 is pushed and we support more than one tablespace
    (explicit tablespace per partition) in various DDL statements,
    and the problem is we do not take MDL locks on all tablespaces in
    use.
    
    Solution:
    Acquire IX MDL lock on tablespace names used by partition and
    sub-partition definitions along with tablespace name used by
    table. We do that in following cases,
    
    1. Lock only the target tablespace name and tablespace
       names that are used by partitions (e.g. CREATE TABLE
       explicitly specifying the tablespace names).
    
    2. Lock only the existing tablespace name and tablespace
       names that are used by partitions (e.g. ALTER TABLE t
       ADD COLUMN ... where t is defined in some tablespace s.
    
    3. Lock both the target and the existing tablespace names
       along with tablespace names used by partitions. (e.g.
       ALTER TABLE t TABLESPACE s2, where t is defined in
       some tablespace s)
    
    4. Lock on tablespace names used by new partitions that are
       added by following command,
    
        => ALTER TABLE <table_name>
             ADD PARTITION
               (PARTITION .. TABLESPACE <tablespace_name>);
    
       Currently lock_table_names() does try and lock partition
       tablespace names that are part of thd->work_part_info as
       Phase 4$ invoking check_and_lock_tablespace_names().
       During ALTER TABLE we currently set thd->work_part_info
       with new partition information bit late after the
       lock_table_names() is done. The fix is to make new
       partition information available in thd->work_part_info
       before we request MDL locks.
    
    5. Lock on tablespace names for the source table and source table
       partitions, in case of CREATE TABLE LIKE.
    
    Tablespace names used by partitions are retrieved by parsing
    the partition expression stored in .FRM. This applies even for
    for NDB tables with partitions before mysql version 50120.
Loading