Mysterious warning

Recently, I was involved in an investigation whose goal was to find out the reason for a warning message like this:

The message looks clear, isn’t it? Well, the problem was that this particular table had not been changed for years, and so no DDL (ALTER) query was involved here. Moreover, there were not even new writes to this table recently, yet this warning was logged occasionally.

Reproduction attempts

In the attempt to reproduce the problem, there was a first obstacle to even create the said table, as it violated the maximum row size. Below I am using a simple test case table definition that illustrates the real issue:

As the table uses the legacy COMPACT row format, the limitation on maximum row size is lower than in the DYNAMIC used by default in modern MySQL versions now, so changing the format would already allow the CREATE to succeed. Still, the customer’s table was there with COMPACT size. Also, the innodb_strict_mode was ON, which prevents such a table’s creation. Notably, the strict mode is by default enabled only since MySQL 5.7, so this table could have been created under MySQL 5.6 in the past.
So, when I create the table with a definition violating the row format limit, we get the expected warning:

A warning gets printed in the error log, which is already a bit confusing as I am not adding a field but creating the table actually:

Table definition cache

Later writing into the table does not trigger any warnings or errors regardless of InnoDB’s strict mode. So why does the warning happen occasionally in the error log? We discovered that it will happen whenever the table object is loaded into the table definition cache! Therefore, it can happen over time whenever the cache becomes too small to fit all user tables. The cache is cleared on restarts, so when I bounce the MySQL instance, and later try to access the same table, this is what happens:

The exact same warning as we saw with CREATE, now also appears in the error log during a simple read:

This is a confusing message, definitely not expected upon a SELECT statement.
Once the table is loaded in the definition cache, the following queries no longer cause the warning!
So, whenever the table definition is not in the cache, any attempt to access it, even running SHOW CREATE TABLE will trigger the same message suggesting that we are adding a field…

Interestingly, when I remove the column to make the table compliant with the limitation, although MySQL executes the command without any complaints, again the confusing error is logged:

Totally not expected to find this log entry upon removing the column 😀

One more quirk about it: an attempt to re-add the culprit column, triggers two warnings instead of one, where one refers to a temporary table created during the ALTER:

Partially, some weirdness of the said message was reported before: https://bugs.mysql.com/bug.php?id=113695, so I decided to file a supplement: https://bugs.mysql.com/bug.php?id=115954

Conclusion

Despite what an error message may suggest, sometimes the reason may be quite unexpected. Never trust it blindly; rather, try to get to the core.


Looking for more essential problem-solving tips? MySQL Performance Tuning is your guide to the most critical aspects of MySQL performance optimization.

 

Download the guide and unlock the full potential of your MySQL database today!

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments