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

ALTER DATA DIRECTORY in PARTITIONS of InnoDB storage does nothing silently

Details

    Description

      It is documented that InnoDB ignores DATA DIRECTORY for partitions on ALTER TABLE. But it ignores it silently and that's an issue. In contrast altering DATA DIRECTORY for table (not partitions) issues a warning for both InnoDB and MyISAM.

      https://mariadb.com/kb/en/library/create-table/#data-directoryindex-directory

      CREATE TABLE t (
      a INT NOT NULL
      ) ENGINE=INNODB
      PARTITION BY HASH (a) (
      PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here/' ENGINE = INNODB,
      PARTITION p2 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here/' ENGINE = INNODB
      );
      INSERT INTO t VALUES (1);
      ALTER TABLE t REORGANIZE PARTITION p1,p2 INTO (
      PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' ENGINE = INNODB,
      PARTITION p2 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_somewhere_else/' ENGINE = INNODB
      );
      SHOW CREATE TABLE t;
      Table	Create Table
      t	CREATE TABLE `t` (
        `a` int(11) NOT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1
      /*!50100 PARTITION BY HASH (a)
      (PARTITION p1 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB,
       PARTITION p2 DATA DIRECTORY = 'MYSQLTEST_VARDIR/tmp/partitions_here' ENGINE = InnoDB) */
      select * from t;
      a
      1
      DROP TABLE t;
      

      The fix is to add a warning for that case.

      Attachments

        Issue Links

          Activity

            • Why not it in warn_if_dir_in_part_elem() ?
            • Why the check for DB_TYPE_INNODB ?
              • The warning "`Warning 1618 <DATA DIRECTORY> option ignored` is issued for any engine
              • No engine-specific checks in the general server code, please
            serg Sergei Golubchik added a comment - Why not it in warn_if_dir_in_part_elem() ? Why the check for DB_TYPE_INNODB ? The warning "`Warning 1618 <DATA DIRECTORY> option ignored` is issued for any engine No engine-specific checks in the general server code, please

            I understand that engine-specific code in sql is not a good idea. But for this particular topic some InnoDB-specific code already exists: https://github.com/MariaDB/server/blob/ada54101a7185782657813c553907f61f2a35faf/sql/ha_partition.cc#L2201

            I've tried first to put my code here, but eventually put it in another place because bool add_or_reorg_part is very handy for my check and I've reused it.

            Right now I can't move that check inside InnoDB because it should work with ALGORITHM=COPY too. Or maybe I don't understand something?

            warn_if_dir_in_part_elem is a different think. Warning should mention InnoDB, because it warns on InnoDB-specific case.

            I've updated PR: added separate WARN_

            kevg Eugene Kosov (Inactive) added a comment - I understand that engine-specific code in sql is not a good idea. But for this particular topic some InnoDB-specific code already exists: https://github.com/MariaDB/server/blob/ada54101a7185782657813c553907f61f2a35faf/sql/ha_partition.cc#L2201 I've tried first to put my code here, but eventually put it in another place because bool add_or_reorg_part is very handy for my check and I've reused it. Right now I can't move that check inside InnoDB because it should work with ALGORITHM=COPY too. Or maybe I don't understand something? warn_if_dir_in_part_elem is a different think. Warning should mention InnoDB, because it warns on InnoDB-specific case. I've updated PR: added separate WARN_
            holyfoot Alexey Botchkov added a comment - - edited

            It feels like i don't understand something. But as far as i can see
            it is not an engine-specific problem. MariaDB ignores DATA DIRECTORY option for all the engines

            MariaDB [test]> CREATE TABLE t (a INT NOT NULL) ENGINE=myisam DATA DIRECTORY = 'maria100/data/partitions_here/';
            Query OK, 0 rows affected (0.09 sec)
             
            MariaDB [test]> alter table t data directory = 'maria100/data/partitions_somewhere_else/';
            Query OK, 0 rows affected, 1 warning (1 min 31.04 sec)
            Records: 0  Duplicates: 0  Warnings: 1
             
            MariaDB [test]> show warnings;
            +---------+------+---------------------------------+
            | Level   | Code | Message                         |
            +---------+------+---------------------------------+
            | Warning | 1618 | <DATA DIRECTORY> option ignored |
            +---------+------+---------------------------------+
            1 row in set (0.00 sec)
            
            

            And that warning is raised in Sql_cmd_alter_table::execute().
            I'd say we should raise same warning for the ALTER REORGANIZE PARTITION
            somewhere there too.

            holyfoot Alexey Botchkov added a comment - - edited It feels like i don't understand something. But as far as i can see it is not an engine-specific problem. MariaDB ignores DATA DIRECTORY option for all the engines MariaDB [test]> CREATE TABLE t (a INT NOT NULL ) ENGINE=myisam DATA DIRECTORY = 'maria100/data/partitions_here/' ; Query OK, 0 rows affected (0.09 sec)   MariaDB [test]> alter table t data directory = 'maria100/data/partitions_somewhere_else/' ; Query OK, 0 rows affected, 1 warning (1 min 31.04 sec) Records: 0 Duplicates: 0 Warnings: 1   MariaDB [test]> show warnings; + ---------+------+---------------------------------+ | Level | Code | Message | + ---------+------+---------------------------------+ | Warning | 1618 | <DATA DIRECTORY> option ignored | + ---------+------+---------------------------------+ 1 row in set (0.00 sec) And that warning is raised in Sql_cmd_alter_table::execute(). I'd say we should raise same warning for the ALTER REORGANIZE PARTITION somewhere there too.

            > it is not an engine-specific problem. MariaDB ignores DATA DIRECTORY option for all the engines

            DATA DIRECTORY for whole table and for partitions are different things.

            Somewhat similar check for partitions happens here https://github.com/MariaDB/server/blob/90b66c169957962de612bc951cdf369cdfccc99c/sql/partition_info.cc#L1606

            If you think it would be better I can merge my function with that one.

            kevg Eugene Kosov (Inactive) added a comment - > it is not an engine-specific problem. MariaDB ignores DATA DIRECTORY option for all the engines DATA DIRECTORY for whole table and for partitions are different things. Somewhat similar check for partitions happens here https://github.com/MariaDB/server/blob/90b66c169957962de612bc951cdf369cdfccc99c/sql/partition_info.cc#L1606 If you think it would be better I can merge my function with that one.
            holyfoot Alexey Botchkov added a comment - - edited

            > > it is not an engine-specific problem. MariaDB ignores DATA DIRECTORY option for all the engines
            > DATA DIRECTORY for whole table and for partitions are different things.

            Do you mean DATA DIRECTORY for the partition tables is engine-specific? I need to see a test case showing that.

            BTW the warn_if_dir_or_idx_in_innodb_part_elem() doesn't warn on that query:

            MariaDB [test]> ALTER TABLE t REORGANIZE PARTITION p1,p2 INTO (
            PARTITION p1 DATA DIRECTORY = '/home/hf/maria103/data/partitions_somewhere_else/', 
            PARTITION p2 DATA DIRECTORY = '/home/hf/maria103/data/partitions_somewhere_else/');
            

            even if the 't' partitions are InnoDB.

            Also I'd note that the warn_if_dir_or_idx_in_innodb_part_elem() only works
            when called from prep_alter_part_table() checking the add_or_reorg_part flag.
            It seems nicer to just do it in the prep_alter_table() then.

            > Somewhat similar check for partitions happens here
            So the warn_if_dir_in_part_elem() checks the MODE_NO_DIR_IN_CREATE flag.
            In fact that flag is checked in many places of the code which i don't like.
            And i'd prefer the ignored-data-directory check in a single place - Sql_cmd_alter_table::execute looks good enough to me.

            holyfoot Alexey Botchkov added a comment - - edited > > it is not an engine-specific problem. MariaDB ignores DATA DIRECTORY option for all the engines > DATA DIRECTORY for whole table and for partitions are different things. Do you mean DATA DIRECTORY for the partition tables is engine-specific? I need to see a test case showing that. BTW the warn_if_dir_or_idx_in_innodb_part_elem() doesn't warn on that query: MariaDB [test]> ALTER TABLE t REORGANIZE PARTITION p1,p2 INTO ( PARTITION p1 DATA DIRECTORY = '/home/hf/maria103/data/partitions_somewhere_else/' , PARTITION p2 DATA DIRECTORY = '/home/hf/maria103/data/partitions_somewhere_else/' ); even if the 't' partitions are InnoDB. Also I'd note that the warn_if_dir_or_idx_in_innodb_part_elem() only works when called from prep_alter_part_table() checking the add_or_reorg_part flag. It seems nicer to just do it in the prep_alter_table() then. > Somewhat similar check for partitions happens here So the warn_if_dir_in_part_elem() checks the MODE_NO_DIR_IN_CREATE flag. In fact that flag is checked in many places of the code which i don't like. And i'd prefer the ignored-data-directory check in a single place - Sql_cmd_alter_table::execute looks good enough to me.
            kevg Eugene Kosov (Inactive) added a comment - - edited

            I've updated PR.

            > Do you mean DATA DIRECTORY for the partition tables is engine-specific? I need to see a test case showing that.

            It's main.partition_not_windows

            Check was moved to prep_alter_part_table(). Table should be opened to perform this check. Sql_cmd_alter_table::execute() is too early, f.ex.

            kevg Eugene Kosov (Inactive) added a comment - - edited I've updated PR. > Do you mean DATA DIRECTORY for the partition tables is engine-specific? I need to see a test case showing that. It's main.partition_not_windows Check was moved to prep_alter_part_table() . Table should be opened to perform this check. Sql_cmd_alter_table::execute() is too early, f.ex.

            > And i'd prefer the ignored-data-directory check in a single place - Sql_cmd_alter_table::execute looks good enough to me.

            It's already in one place and works for both ALTER TABLE and CREATE TABLE. If I'll move that check to Sql_cmd_alter_table::execute() I will also have to duplicate it somewhere for CREATE TABLE.

            kevg Eugene Kosov (Inactive) added a comment - > And i'd prefer the ignored-data-directory check in a single place - Sql_cmd_alter_table::execute looks good enough to me. It's already in one place and works for both ALTER TABLE and CREATE TABLE . If I'll move that check to Sql_cmd_alter_table::execute() I will also have to duplicate it somewhere for CREATE TABLE .
            holyfoot Alexey Botchkov added a comment - https://github.com/MariaDB/server/commit/031c695b8c865e5eb6c4c09ced404ae08f98430f

            People

              holyfoot Alexey Botchkov
              kevg Eugene Kosov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.