Bug #71292 Wrong length is used for FILE_NAME column in FILE_INSTANCES table
Submitted: 4 Jan 2014 18:09 Modified: 6 Jan 2014 13:17
Reporter: Valeriy Kravchuk Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Performance Schema Severity:S3 (Non-critical)
Version:5.6.15 OS:Any
Assigned to: Marc ALFF CPU Architecture:Any
Tags: file_instances, FILE_NAME, MAX_PATH, performance_schema

[4 Jan 2014 18:09] Valeriy Kravchuk
Description:
I see that on both Windows and Linux FILE_NAME column in PERFORMANCE_SCHEMA.FILE_INSTANCES table is defined as varchar(512):

mysql> desc performance_schema.file_instances;
+------------+------------------+------+-----+---------+-------+
| Field      | Type             | Null | Key | Default | Extra |
+------------+------------------+------+-----+---------+-------+
| FILE_NAME  | varchar(512)     | NO   |     | NULL    |       |
| EVENT_NAME | varchar(128)     | NO   |     | NULL    |       |
| OPEN_COUNT | int(10) unsigned | NO   |     | NULL    |       |
+------------+------------------+------+-----+---------+-------+
3 rows in set (0,00 sec)

It's probably an overkill for Windows (where API allows to use up to 32K for NTFS, but only up to 255 in the command line, see http://en.wikipedia.org/wiki/Comparison_of_file_systems), but surely not enough for Linux, where (depending on filesystem) pathname (and FILE_NAME actually contains full pathname) maybe even unlimited, and related limit is defined (by POSIX?) as 4096:

openxs@ao756:~$ grep PATH_MAX /usr/include/linux/limits.h
#define PATH_MAX        4096    /* # chars in a path name including nul */

How to repeat:
Try to use datadir with pathname containing several (3+) directory names of NAME_MAX characters (255) and then check what file_instances will report in FILE_NAME.

Suggested fix:
Make FILE_NAME column data type long enough to cover all acceptable full pathnames in POSIX-compatible OSes.
[6 Jan 2014 12:35] MySQL Verification Team
Hello Valeriy,

Thank you for the bug report.
Verified as described.

Thanks,
Umesh
[6 Jan 2014 13:16] Marc ALFF
The length is correct.

malff@linux-3ezv:include> pwd
/home/malff/BZR_TREE/mysql-trunk/include
malff@linux-3ezv:include> grep FN_REFLEN *.h
my_global.h:#define FN_REFLEN   512     /* Max length of full path-name */

The MySQL code, because of FN_REFLEN in the mysys library, only uses file names limited to 512 characters.

The fact that a given platform *might* support longer file names is not a sufficient condition to ensure that the MySQL server *will* uses file names that long.

This restriction, for better or worse, comes from the historical design of mysys.

I agree that, in theory, a plugin may perform file io directly, without using the mysys file io wrappers, and need longer file names, in which case the performance schema max file name length supported is a limitation.

Closing as not a bug.