[MDEV-11014] cannot create table with DATA/INDEX DIRECTORY clause Created: 2016-10-10  Updated: 2016-10-11  Resolved: 2016-10-11

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table
Affects Version/s: 10.1.9, 10.1.12
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Karl Assignee: Unassigned
Resolution: Not a Bug Votes: 0
Labels: None
Environment:

Ubuntu 14.04.5 LTS (10.1.12), Windows 10 (10.1.9)


Attachments: Text File MySQLCurrentSettings.txt    

 Description   

both target directories exist and have proper rights

Ubuntu:

>create table test.otherlocation (id int) ENGINE=MyISAM, DATA DIRECTORY='/tmp/datadir', INDEX DIRECTORY='/tmp/datadir';
ERROR 1 (HY000): Can't create/write to file '/tmp/datadir/otherlocation.MYI' (Errcode: 2 "No such file or directory")

Windows:

>create table test.otherlocation (id int) ENGINE=MyISAM, DATA DIRECTORY='/tmp/datadir', INDEX DIRECTORY='/tmp/datadir';
ERROR 1103 (42000): Incorrect table name '/tmp/datadir'



 Comments   
Comment by Karl [ 2016-10-11 ]

I copied the above statement from stackoverflow and see that there might be a typo: no commas. But

Ubuntu:

>create table test.otherlocation (id int) ENGINE=MyISAM DATA DIRECTORY='/tmp/datadir' INDEX DIRECTORY='/tmp/datadir';
ERROR 1 (HY000): Can't create/write to file '/tmp/datadir/otherlocation.MYI' (Errcode: 2 "No such file or directory")

>SHOW VARIABLES LIKE 'tmpd%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| tmpdir        | /tmp/ |
+---------------+-------+
1 row in set (0.07 sec)

ubuntu@ip-172-31-30-16:~$ ll /tmp/datadir/
total 32
drwxrwxr-x 2 ubuntu libuuid  4096 Oct 10 15:52 ./
drwxrwxrwt 3 root   root    24576 Oct 11 16:44 ../

These are the same owner rights used for the database proper.

Windows:

:>create table test.otherlocation (id int) ENGINE=MyISAM DATA DIRECTORY='/tmp/datadir' INDEX DIRECTORY='/tmp/datadir';
ERROR 1103 (42000): Incorrect table name '/tmp/datadir'

>SHOW VARIABLES LIKE 'tmpd%';
+-------------------+-------+
| Variable_name     | Value |
+-------------------+-------+
| tmpdir            | /tmp/ |
+-------------------+-------+

C:\>dir tmp\datadir
 Volume in Laufwerk C: hat keine Bezeichnung.
 Volumeseriennummer: EEA1-5DB7
 
 Verzeichnis von C:\tmp\datadir
 
11.10.2016  16:40    <DIR>          .
11.10.2016  16:40    <DIR>          ..
               0 Datei(en),              0 Bytes
               2 Verzeichnis(se), 394.846.883.840 Bytes frei

Comment by Elena Stepanova [ 2016-10-11 ]

There are several problems/questions described here, let's tackle them one by one.

1.

Windows:
 
>create table test.otherlocation (id int) ENGINE=MyISAM, DATA DIRECTORY='/tmp/datadir', INDEX DIRECTORY='/tmp/datadir';
ERROR 1 (HY000): Can't create/write to file '/tmp/datadir/otherlocation.MYI' (Errcode: 2 "No such file or directory")

It is not supposed to work; there is no /tmp/datadir on WIndows, it's c:/tmp/datadir.
If you put DIRECTORY='c:/tmp/datadir', it shouldn't fail.
However, please note that these table options don't work on Windows anyway, they should be ignored with a warning. MariaDB on Windows has NO in SELECT @@have_symlink.

2.

Windows:
 
>SHOW VARIABLES LIKE 'tmpd%';
+-------------------+-------+
| Variable_name     | Value |
+-------------------+-------+
| tmpdir            | /tmp/ |
+-------------------+-------+

This is a mystery #1. How did you achieve it? Are you sure it's not a copy-paste error?
Please attach the complete output of SHOW GLOBAL VARIABLES (it will be quite long, you can put it in a file).

3.

Ubuntu: 
>create table test.otherlocation (id int) ENGINE=MyISAM, DATA DIRECTORY='/tmp/datadir', INDEX DIRECTORY='/tmp/datadir';
ERROR 1 (HY000): Can't create/write to file '/tmp/datadir/otherlocation.MYI' (Errcode: 2 "No such file or directory")

This is a mystery #2.
Unless something is very wrong with the Ubuntu installation, It is supposed to work and works for me, if the server can write to the directory (and if it can't, the error should be different). But just in case, is it certain that the user which runs mysqld (probably mysql user?) can run read and write into the directory? I know you said in the description that it has "proper" permissions, but since it's not obvious from the folder ownership, it does not hurt to double-check.

Where does the server come from? Did you install a package, or did you build it from source?

  • if you installed a package, please paste the output of dpkg -l | grep -iE 'mysql|maria';
  • if you built from source, please paste all cmake options and additional flags that you used, and make sure that the sources are pristine;
  • attach the complete output of SHOW GLOBAL VARIABLES;
  • check if there are any otherlocation.* files in <regular datadir>/test.
  • attach the server error log from the last server startup and till the error is triggered.
Comment by Karl [ 2016-10-11 ]

I hope I understood formatting instructions by your example – I used the Style drop down menu (preformatted) earlier, to no avail.

#1:
Ok, SELECT @@have_symlink. is NO

My Master :ci4:>create table test.otherlocation (id int) ENGINE=MyISAM, DATA DIRECTORY='c:/tmp/datadir', INDEX DIRECTORY='c:/tmp/datadir';
Query OK, 0 rows affected, 2 warnings (0.26 sec)
 
My Master :ci4:>insert into test.otherlocation values(2),(9);
Query OK, 2 rows affected (0.10 sec)
Records: 2  Duplicates: 0  Warnings: 0
 
My Master :ci4:>select * from test.otherlocation ;
+------+
| id   |
+------+
|    2 |
|    9 |
+------+
2 rows in set (0.11 sec)

And the table has been created in the default database directory.

#2:

MySQLCurrentSettings.txt

excerpt from my.ini:

# Point the following paths to a dedicated disk
tmpdir		= /tmp/

The code resides on C:\xampp\MariaDB 10.1\bin, so tmpdir should point to c:\tmp and not d:\tmp where the datadase directory is.

#3:

I work with docker on AWS. I made sure the permissions are identical to those of the datadir - which should be mysql:mysql normally, and I don't know out off my head why it is different here.

BUT: I made a mistake here... /tmp in my container does not point to /tmp on my host, so it is stupid to create a subdirectory there...

M:2813781 [ci4]>create table test.otherlocation (id int) ENGINE=MyISAM, DATA DIRECTORY='/tmp', INDEX DIRECTORY='/tmp';
Query OK, 0 rows affected (0.04 sec)

ubuntu@ip-172-31-30-16:~$ docker exec -it $id ash
/ # ls -la /tmp
total 64
drwxrwxrwx    2 root     root          4096 Oct 11 20:54 .
drwxr-xr-x   36 root     root          4096 Oct 11 20:51 ..
-rw-rw-r--    1 root     root         50172 Jun 13 19:17 mha4mysql-node-0.56.tar.gz
-rw-rw----    1 mysql    mysql            0 Oct 11 20:54 otherlocation.MYD
-rw-rw----    1 mysql    mysql         1024 Oct 11 20:54 otherlocation.MYI

I was led to this false assumption as the actual datadir of the container is mapped to the host, of course.

Actually I wanted to use symlinks both on ibd and myisam files. Now I see why this could not work. The datadir was mapped, but the destinations I chose were not, so they were not visible from within the container....

Thanks a lot to sort this out. I am so comfortable with docker these days I just forget about the assumptions and restrictions.

Comment by Elena Stepanova [ 2016-10-11 ]

Okay, then I guess all mysteries are resolved for now. Good luck!

Generated at Thu Feb 08 07:46:39 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.