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

ALTER .. ORDER BY with NOCOPY/INSTANT algorithm breaks OM=>NS replication

    XMLWordPrintable

Details

    Description

      --source include/have_innodb.inc
       
      CREATE TABLE t (pk INT PRIMARY KEY, a INT) ENGINE=InnoDB;
      INSERT INTO t VALUES (1,1); # Optional, does not affect the outcome
      ALTER TABLE t ALGORITHM=INSTANT, ORDER BY a; # Also can be ALGORITHM=INSTANT
       
      DROP TABLE t;
      

      Before 11.2 the above succeeds with a warning:

      11.1.6

      worker[01] Using MTR_BUILD_THREAD 300, with reserved ports 19000..19029
      CREATE TABLE t (pk INT PRIMARY KEY, a INT) ENGINE=InnoDB;
      INSERT INTO t VALUES (1,1);
      ALTER TABLE t ALGORITHM=INSTANT, ORDER BY a;
      Warnings:
      Warning	1105	ORDER BY ignored as there is a user-defined clustered index in the table 't'
      DROP TABLE t;
      

      Starting from 11.2, it fails with ER_ALTER_OPERATION_NOT_SUPPORTED:

      main 2ee2e2d0f3d3dbfafebdb75ee7bc2914b97e9065

      CREATE TABLE t (pk INT PRIMARY KEY, a INT) ENGINE=InnoDB;
      INSERT INTO t VALUES (1,1);
      ALTER TABLE t ALGORITHM=INSTANT, ORDER BY a;
      bug.t3                                   [ fail ]
              Test ended at 2025-06-23 09:29:24
       
      CURRENT_TEST: bug.t3
      mysqltest: At line 5: query 'ALTER TABLE t ALGORITHM=INSTANT, ORDER BY a' failed: ER_ALTER_OPERATION_NOT_SUPPORTED (1845): ALGORITHM=INSTANT is not supported for this operation. Try ALGORITHM=COPY
      

      Consequently, when such an ALTER is executed on a pre-11.2 primary, it succeeds, gets written into the binlog, fails on a replica, and causes a replication abort.

      The new behavior was introduced in 11.2 by online alter changes, specifically it started happening after this commit:

      commit 43cb98b42070dc209063792ac06e4e24484d45f3
      Author: Nikita Malyavin
      Date:   Wed Jun 28 14:37:47 2023 +0300
       
          fix main.mysql57_virtual, main.alter_table, innodb.alter_algorithm
      

      Attachments

        Issue Links

          Activity

            People

              nikitamalyavin Nikita Malyavin
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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