I've got a MariaDB instance (10.6.8
) hosted on Amazon RDS (db.m6g.4xlarge
). It had automatic minor upgrades enabled, which unfortunately caused hours of downtime last time it triggered.
In reviewing the logs, it seems the issue was that a few of our biggest tables needed to be rebuilt before the upgrade could be done.
error : Table rebuild required. Please do "ALTER TABLE 'my_table' FORCE" or dump/reload to fix it!
Each was taking multiple hours. The biggest has ~170 million rows and 20 columns.
In the worst case, we can schedule downtime, I guess. But if there's some way to do things differently so that this won't be an issue going forward, that'd be preferable.
So far, I've investigated:
- Add pruning to avoid keeping old, unneeded data in some of those tables. This makes them small enough that rebuilding doesn't cause hours of downtime
- In the future, do and schedule my own minor upgrades, run
mysqlcheck
ahead of time, and at least know beforehand what tables might need to be rebuilt. This still isn't ideal because theALTER TABLE 'my_table' FORCE
command locks the table, which of course also causes downtime for our application - Presume the required table rebuild is unlikely to happen again. Implement an automated rebuild that selects chunks of the old table and inserts them into a new table until their contents match. Then delete the old table and rename the new table to the old one's name. This would work--but takes time, and would need to be done each time a table needs to be rebuilt
- Split the big table(s) logically into different tables with the same schema. If data access patterns don't often require querying from more than one at a time, I could then limit the locking done for a rebuild to one (smaller) table at a time, instead of locking to rebuild the big table all at once
Ideally, I'd like to be able to turn on automatic minor version upgrades again, and it "just work" with minimal downtime in a pre-selected window.
SHOW CREATE TABLE
for the table that required the rebuild. Complain to Amazon.SHOW CREATE TABLE
output, but these were all basic tables with no foreign keys, triggers, etc.ENGINE
is being used on the tables?