[MDEV-16594] ALTER DATA DIRECTORY in PARTITIONS of InnoDB storage does nothing silently Created: 2018-06-27  Updated: 2019-09-09  Resolved: 2019-09-09

Status: Closed
Project: MariaDB Server
Component/s: Partitioning, Storage Engine - InnoDB
Affects Version/s: 10.0.35
Fix Version/s: 10.1.42

Type: Bug Priority: Minor
Reporter: Eugene Kosov (Inactive) Assignee: Alexey Botchkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-14618 "reorganize partition" ignores "data ... Open
relates to MDEV-15953 Alter InnoDB Partitioned Table Moves ... Closed

 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.



 Comments   
Comment by Sergei Golubchik [ 2018-07-17 ]
  • 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
Comment by Eugene Kosov (Inactive) [ 2018-07-18 ]

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_

Comment by Alexey Botchkov [ 2018-07-31 ]

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.

Comment by Eugene Kosov (Inactive) [ 2018-08-01 ]

> 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.

Comment by Alexey Botchkov [ 2018-08-03 ]

> > 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.

Comment by Eugene Kosov (Inactive) [ 2018-08-07 ]

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.

Comment by Eugene Kosov (Inactive) [ 2018-08-08 ]

> 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.

Comment by Alexey Botchkov [ 2019-09-09 ]

https://github.com/MariaDB/server/commit/031c695b8c865e5eb6c4c09ced404ae08f98430f

Generated at Thu Feb 08 08:30:05 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.