Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-27962

Instant DDL downgrades the MDL when table is empty

Details

    Description

      MDEV-23805 fails to avoid the downgrade of MDL during inplace alter operation.

      Condition was misplaced :

      diff --git a/sql/sql_table.cc b/sql/sql_table.cc
      index 03df92cd484..eb57242edbe 100644
      --- a/sql/sql_table.cc
      +++ b/sql/sql_table.cc
      @@ -7258,16 +7258,15 @@ static bool mysql_inplace_alter_table(THD *thd,
           lock for prepare phase under LOCK TABLES in the same way as when
           exclusive lock is required for duration of the whole statement.
         */
      -  if (!ha_alter_info->mdl_exclusive_after_prepare &&
      -      (inplace_supported == HA_ALTER_INPLACE_EXCLUSIVE_LOCK ||
      -       ((inplace_supported == HA_ALTER_INPLACE_COPY_NO_LOCK ||
      +  if (inplace_supported == HA_ALTER_INPLACE_EXCLUSIVE_LOCK ||
      +      ((inplace_supported == HA_ALTER_INPLACE_COPY_NO_LOCK ||
               inplace_supported == HA_ALTER_INPLACE_COPY_LOCK ||
               inplace_supported == HA_ALTER_INPLACE_NOCOPY_NO_LOCK ||
               inplace_supported == HA_ALTER_INPLACE_NOCOPY_LOCK ||
               inplace_supported == HA_ALTER_INPLACE_INSTANT) &&
              (thd->locked_tables_mode == LTM_LOCK_TABLES ||
               thd->locked_tables_mode == LTM_PRELOCKED_UNDER_LOCK_TABLES)) ||
      -      alter_info->requested_lock == Alter_info::ALTER_TABLE_LOCK_EXCLUSIVE))
      +      alter_info->requested_lock == Alter_info::ALTER_TABLE_LOCK_EXCLUSIVE)
         {
           if (wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN))
             goto cleanup;
      @@ -7379,7 +7378,8 @@ static bool mysql_inplace_alter_table(THD *thd,
           necessary only for prepare phase (unless we are not under LOCK TABLES) and
           user has not explicitly requested exclusive lock.
         */
      -  if ((inplace_supported == HA_ALTER_INPLACE_COPY_NO_LOCK ||
      +  if (!ha_alter_info->mdl_exclusive_after_prepare &&
      +      (inplace_supported == HA_ALTER_INPLACE_COPY_NO_LOCK ||
              inplace_supported == HA_ALTER_INPLACE_COPY_LOCK ||
              inplace_supported == HA_ALTER_INPLACE_NOCOPY_LOCK ||
              inplace_supported == HA_ALTER_INPLACE_NOCOPY_NO_LOCK) &&
      

      Attachments

        Issue Links

          Activity

            thiru Thirunarayanan Balathandayuthapani created issue -
            thiru Thirunarayanan Balathandayuthapani made changes -
            Field Original Value New Value
            Affects Version/s 10.7.2 [ 26813 ]
            Affects Version/s 10.6.6 [ 26811 ]
            Affects Version/s 10.5.14 [ 26809 ]
            Affects Version/s 10.4.23 [ 26807 ]
            thiru Thirunarayanan Balathandayuthapani made changes -
            Fix Version/s 10.4 [ 22408 ]
            Fix Version/s 10.5 [ 23123 ]
            Fix Version/s 10.6 [ 24028 ]
            Fix Version/s 10.7 [ 24805 ]
            thiru Thirunarayanan Balathandayuthapani made changes -
            Component/s Storage Engine - InnoDB [ 10129 ]
            thiru Thirunarayanan Balathandayuthapani made changes -
            Description MDEV-23805 fails to avoid the downgrade of MDL during inplace alter operation.

            Condition was misplaced :
            {code}
            diff --git a/sql/sql_table.cc b/sql/sql_table.cc
            index 03df92cd484..eb57242edbe 100644
            --- a/sql/sql_table.cc
            +++ b/sql/sql_table.cc
            @@ -7258,16 +7258,15 @@ static bool mysql_inplace_alter_table(THD *thd,
                 lock for prepare phase under LOCK TABLES in the same way as when
                 exclusive lock is required for duration of the whole statement.
               */
            - if (!ha_alter_info->mdl_exclusive_after_prepare &&
            - (inplace_supported == HA_ALTER_INPLACE_EXCLUSIVE_LOCK ||
            - ((inplace_supported == HA_ALTER_INPLACE_COPY_NO_LOCK ||
            + if (inplace_supported == HA_ALTER_INPLACE_EXCLUSIVE_LOCK ||
            + ((inplace_supported == HA_ALTER_INPLACE_COPY_NO_LOCK ||
                     inplace_supported == HA_ALTER_INPLACE_COPY_LOCK ||
                     inplace_supported == HA_ALTER_INPLACE_NOCOPY_NO_LOCK ||
                     inplace_supported == HA_ALTER_INPLACE_NOCOPY_LOCK ||
                     inplace_supported == HA_ALTER_INPLACE_INSTANT) &&
                    (thd->locked_tables_mode == LTM_LOCK_TABLES ||
                     thd->locked_tables_mode == LTM_PRELOCKED_UNDER_LOCK_TABLES)) ||
            - alter_info->requested_lock == Alter_info::ALTER_TABLE_LOCK_EXCLUSIVE))
            + alter_info->requested_lock == Alter_info::ALTER_TABLE_LOCK_EXCLUSIVE)
               {
                 if (wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN))
                   goto cleanup;
            @@ -7379,7 +7378,8 @@ static bool mysql_inplace_alter_table(THD *thd,
                 necessary only for prepare phase (unless we are not under LOCK TABLES) and
                 user has not explicitly requested exclusive lock.
               */
            - if ((inplace_supported == HA_ALTER_INPLACE_COPY_NO_LOCK ||
            + if (!ha_alter_info->mdl_exclusive_after_prepare &&
            + (inplace_supported == HA_ALTER_INPLACE_COPY_NO_LOCK ||
                    inplace_supported == HA_ALTER_INPLACE_COPY_LOCK ||
                    inplace_supported == HA_ALTER_INPLACE_NOCOPY_LOCK ||
                    inplace_supported == HA_ALTER_INPLACE_NOCOPY_NO_LOCK) &&
            {code}
            thiru Thirunarayanan Balathandayuthapani made changes -
            thiru Thirunarayanan Balathandayuthapani made changes -
            Assignee Thirunarayanan Balathandayuthapani [ thiru ]
            thiru Thirunarayanan Balathandayuthapani made changes -
            Fix Version/s 10.4.25 [ 27510 ]
            Fix Version/s 10.5.16 [ 27508 ]
            Fix Version/s 10.6.8 [ 27506 ]
            Fix Version/s 10.7.4 [ 27504 ]
            Fix Version/s 10.8.3 [ 27502 ]
            Fix Version/s 10.4 [ 22408 ]
            Fix Version/s 10.5 [ 23123 ]
            Fix Version/s 10.6 [ 24028 ]
            Fix Version/s 10.7 [ 24805 ]
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Closed [ 6 ]

            People

              thiru Thirunarayanan Balathandayuthapani
              thiru Thirunarayanan Balathandayuthapani
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.