Amazon RDS – How to Handle NULL CREATE_TIME in INFORMATION_SCHEMA.TABLES

amazon-rdsinformation-schema

We are running an Amazon Aurora database that emulates MySQL 5.6.10. The CREATE_TIME in SHOW TABLE STATUS and INFORMATION_SCHEMA.TABLES is consistently NULL for all our tables.

Is this a bug, a limitation of Aurora's architecture, or am I doing something wrong? Is this information available anyplace else?

db2 information_schema> SELECT DISTINCT TABLE_SCHEMA 
FROM information_schema.TABLES WHERE CREATE_TIME IS NOT NULL;
+--------------------+
| TABLE_SCHEMA       |
+--------------------+
| information_schema |
| mysql              |
+--------------------+
2 rows in set (9.00 sec)

Additional notes: We have several thousand tables across several hundred databases, on several different hosts; many of the tables were created with files-per-table on, and some with it off. We do not have access to the .frm files, and they may or may not exist in Aurora. This has always worked for us in MySQL.

Update: Amazon support told us, vaguely, this is a bug and "it will be corrected in a later release." Still interested in knowing if this is going to be retroactively available, or if there is another place to get this 'cause Amazon is not elaborating.

Best Answer

This was the response from AWS - they agree using the TABLE_COMMENT column is the way forward. I can also confirm we have successfully implemented this solution.

Hello,

Thank you for contacting AWS premium support. My name is Vidyadhar and I am glad to assist you on this case.

From the case description, I understand that you noticed only null values in create_time column in information_schema.tables. You were removing old tables based on the values inside this column in MySQL. Now, you would like to know reason for not showing up creation time in Aurora and alternatives to achieve your requirement.

Just to let you know, there is a known bug in MySQL related to the same where create_time will be null for partitioned columns. This has been fixed in MySQL 5.6.25 version. Please look into below link for reference.

https://bugs.mysql.com/bug.php?id=69990

In aurora this column will be NULL for all tables including partitioned tables. This has been already notified to the service team. Also, there is no workaround to this available in Aurora for now.

It is best option to utilize the table comment session as a work around to note the time of table creation and proceed accordingly with table deletion. You can look into TABLE_COMMENT column in information_schema.tables. Please refer to below example which might be helpful.

MySQL [test]> create table S1(id int) comment='2017-09-21 15:53:51';
Query OK, 0 rows affected (0.02 sec)

MySQL [test]>  show create table S1\G
*************************** 1. row ***************************
       Table: S1 Create Table: CREATE TABLE `S1` (   `id` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1
COMMENT='2017-09-21 15:53:51' 1 row in set (0.00 sec)

MySQL [test]> select TABLE_SCHEMA,TABLE_NAME,TABLE_COMMENT from
information_schema.tables where table_schema='test' and
table_name='S1';
+--------------+------------+---------------------+ 
| TABLE_SCHEMA | TABLE_NAME | TABLE_COMMENT       |
+--------------+------------+---------------------+ 
| test         | S1         | 2017-09-21 15:53:51 |
+--------------+------------+---------------------+ 
1 row in set (0.01 sec)

I truly apologize for the inconvenience caused. Aurora service team is working hard to add features and fixing bugs. As of now, I am unable to provide any ETA but definitely this will be fixed in future versions.

I hope this information is helpful. Please feel free to reach me if you have any further questions or concerns.

Have a great day!