MySQL 8.0 – Increased Disk Consumption After Upgrade

MySQLmysql-8.0

I have a MySQL 8 DB in AWS RDS, and after upgrading from MySQL 5.7 to 8 a couple months ago, we have noticed free disk space being consumed at a very rapid rate, at least double the previous rate.

One particular table shows about 500GB of data_length + index_length when querying against INFORMATION_SCHEMA.TABLES, and yet its .ibd file is allocated to over 1TB on disk when querying INFORMATION_SCHEMA.FILES or INFORMATION_SCHEMA.INNODB_TABLESPACES (we have innodb_per_file_table=1). There is very little fragmentation, judging by the comparison of data_free against the data + index length.

How can I find the cause of the increased disk consumption rate? Is there anything inherent to MySQL 8 that uses more disk? Our application hasn't changed, but it does have rather large JSON columns — possibly something in MySQL 8 handles JSON on disk in a less efficient way?

Best Answer

This is most likely because of a bug in the version of mysql you are using. The issue is that mysql does not release its file handle on temporary files until you restart mysqld. This is a confirmed bug and you can read others experience with it here.

Upgrading past 8.0.15 should have resolved the issue.