Bug #74591 InnoDB: Recognize different path strings that point to the same location
Submitted: 27 Oct 2014 13:56 Modified: 8 Jul 2015 14:44
Reporter: Kevin Lewis Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:5.7.6 OS:Any
Assigned to: CPU Architecture:Any

[27 Oct 2014 13:56] Kevin Lewis
If the datadir location is changed from a realtive path to a full path, InnoDB will still have the realtive path embedded if tablespace file locations in its data dictionary (SYS_DATABASES).  The open process will find what it thinks is two different files for the same tablespace, one from the 'dictionary' location and one from the 'default' location. InnoDB will them refuse to open the tablespace.

This problem did not exist before the following patch because the dictionary was not consulted for ibd files in the default datadir.

revno: 9124
revision-id: kevin.lewis@oracle.com-20141026125237-w8ahe5o6u34616aq
parent: praveenkumar.hulakund@oracle.com-20141024181608-u6s1e57wqkvyrwdm
committer: kevin.lewis@oracle.com
branch nick: mysql-trunk
timestamp: Sun 2014-10-26 07:52:37 -0500
                        AND TABLESPACES
  Restructure dict_check_tablespaces_and_store_max_id(() so that it
  calls a new function dict_check_sys_tables(). This function uses
  dict_startscan_system() and dict_getnext_system() to step through
  the system table which is different from the direct way it did before,
  and the code can be more easily used for the GlobalDD, hopefully.
  Then for each SYS_TABLES table, it calls a new function
  dict_sys_tables_rec_read() which does the read, much like the original
  code in dict_check_tablespaces_and_store_max_id().
  The major difference is that previously, the filepath was read from
  SYS_DATAFILES only if a file-per-table tablespace was created with
  the DATA DIRECTORY phrase.  Now, the filepath in SYS_DATAFILES will
  be referenced for every non-system tablespace.  This change affected
  several testcases.
  The parameters to dict_check_tablespaces_and_store_max_id(),
  (recv_needed_recovery and dict_check), were consolidated to just a
  'bool validate', which is set true if recovery was needed.
  The portion of dict_load_table_one() that loads a tablespace while
  loading a table is put it into its own inline function called
  Approved by Marko in rb#6982

How to repeat:
See the testcase main.mysql_embedded.test.  The patch referenced added error suppression that indicates ibd files are not being opened when the default datadir is changed from "./" to a full path by using the embedded engine.  Strangely enough, the test succeeds even though critical tables in the "mysql" database are no longer being opened by the embedded engine.

Suggested fix:
In preparation for the Global DD, it is imperative that this change is made, that InnoDB start using the data dictionary for filepath locations instead of making up a filepath on the fly from the datadir and using only that.

So InnoDB must be taught how to recognize when two paths are pointing to the same location even if they look different textually (with a string comparison).
[8 Jul 2015 14:44] Daniel Price
Posted by developer:
Fixed as of the upcoming 5.7.8, 5.8.0 release, and here's the changelog entry:

InnoDB failed to open a tablespace after the data directory location of
the tablespace was changed from a relative path to a full path. InnoDB
failed to recognize that the relative path, which remained embedded in the
data dictionary, pointed to the same data file as the full path.