Bug #15851 Unlistable directories yield no info from information_schema
Submitted: 19 Dec 2005 11:31 Modified: 26 Jan 2006 3:16
Reporter: Björn Wiberg
Status: Closed
Category:Server Severity:S3 (Non-critical)
Version:5.0.16 OS:Any (IBM AIX 5.3 ML2)
Assigned to: Sergey Gluhov Target Version:

[19 Dec 2005 11:31] Björn Wiberg
Description:
If a subdirectory (database) in the MySQL data directory doesn't allow for reading ("r"
flag) for the user that the MySQL server runs as, listing metadata from the
information_schema database fails with errno 13 instead of showing what it can show about
the other databases.

This happens, for instance, if the data directory is a file system of its own, hence
containing a "lost+found" directory, which the system administrators have chosen to
restrict access to.

Best regards,
Björn

How to repeat:
root@aramus:/mysql/data# chmod og-r lost+found 

root@aramus:/mysql/data# mysql -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1471 to server version: 5.0.16-standard-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

root@localhost (none)> use information_schema;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
root@localhost information_schema> show tables;
+---------------------------------------+
| Tables_in_information_schema          |
+---------------------------------------+
| CHARACTER_SETS                        |
| COLLATIONS                            |
| COLLATION_CHARACTER_SET_APPLICABILITY |
| COLUMNS                               |
| COLUMN_PRIVILEGES                     |
| KEY_COLUMN_USAGE                      |
| ROUTINES                              |
| SCHEMATA                              |
| SCHEMA_PRIVILEGES                     |
| STATISTICS                            |
| TABLES                                |
| TABLE_CONSTRAINTS                     |
| TABLE_PRIVILEGES                      |
| TRIGGERS                              |
| VIEWS                                 |
| USER_PRIVILEGES                       |
+---------------------------------------+
16 rows in set (0.00 sec)

root@localhost information_schema> select * from TABLES;
ERROR 1018 (HY000): Can't read dir of './lost+found/' (errno: 13)
root@localhost information_schema> quit
Bye

Suggested fix:
chmod og+r lost+found

..which in this case, will allow the "lost+found" directory to be listed by MySQL.
[19 Dec 2005 14:24] Valeriy Kravchuk
Thank you for a problem report. In all the installation instructions in the manual it is
always stated, that data directory should belong to the user that runs mysqld. Take a look
at http://dev.mysql.com/doc/refman/5.0/en/installing-binary.html, for example. Just for
the user to be able to read the directories and files in them.

When you select from TABLES in the information_schema, the databases are being scanned for
tables, hence the problem when there is no read access, or when lost+found is scanned.

So, I think it is not a bug. You may call it a documentation request (documentation should
explicitely mention that making data directory a mount point is not a good idea) or a
feature request (to skip lost+found subdirectory). What do you think?
[19 Dec 2005 17:50] Björn Wiberg
Hello Valeriy!

Thank you for your reply!

I agree that this is not the normal case, and not recommended, however, I would prefer to
see MySQL skipping the directories it cannot read with a warning instead of incorrectly
indicating (in the information_schema view of metadata) that no metadata exists.

But, in case that is not possible, mentioning this in the documentation would be an
option. (That *all* directories in the data directory *must* be readable by the MySQL
user, or metadata reporting will fail.)

Wishing you a Merry Christmas and a Happy New Year!

Best regards,
Björn
[20 Dec 2005 11:20] Valeriy Kravchuk
So, the documentation should mention in the prominent place, that all directories in the
data directory must be readable by the MySQL user, or metadata reporting will fail. The
advice not to use any filesystem mount point as a data directory should be also added.
[23 Dec 2005 12:14] Sergei Golubchik
There's already code in MySQL to skip hidden/system directories on Windows,
we can do the same with unreadable directories too
[16 Jan 2006 16:21] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/1147
[24 Jan 2006 12:54] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/1556
[24 Jan 2006 13:07] Sergey Gluhov
Fixed in 5.0.19
[26 Jan 2006 3:16] Mike Hillyer
Documented in 5.0.19 changelog:

      <listitem>
        <para>
          The <literal>INFORMATION_SCHEMA</literal> now skips data
          contained in unlistable/unreadable directories rather than
          returning an error. (Bug #15851)
        </para>
      </listitem>

Users are already explicitly instructed to chown -R the data directory and server install
directory.
[1 Mar 2006 21:59] Magnus Blaudd
The testcase for this bug does not work on Windows.
[11 Apr 2006 15:46] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/4800