Description:
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
message:
Bug #19884605 INNODB: REFACTOR CODE RELATED TO LOADING TABLES
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
dict_load_tablespace().
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).