If you do not delete the data files on your ApsaraDB RDS for MySQL instance for a long period of time, the storage capacity of the RDS instance may be exhausted. As a result, your RDS instance is automatically locked to prevent data loss, and you cannot write data to your RDS instance.
Problem description
A large amount of data is written to your RDS instance. As a result, the storage capacity of the RDS instance is exhausted by data files, and the RDS instance enters the Locked state.
Cause
The storage capacity of an RDS instance is exhausted by the data files that are retained for a long period of time. In this case, the RDS instance is automatically locked to prevent data loss, and you cannot write data to your RDS instance.
Solution
Prerequisites
Usage notes
- Before you delete a table, make sure that the table data is backed up to prevent loss.
- If you use an ApsaraDB RDS for MySQL instance, you cannot execute the
DELETE
statement to release the storage of the RDS instance. We recommend that you execute theDROP
orTRUNCATE
statement to release the storage of the RDS instance. - If you execute the
OPTIMIZE
statement on a table, the table becomes locked. We recommend that you execute the OPTIMIZE statement during off-peak hours. - After data files are deleted, a period of time is required to release the storage of your RDS instance.
- After data files are deleted, ApsaraDB RDS unlocks your RDS instance in approximately 5 minutes.
Procedure
You can use one of the following methods to resolve the issue:
- Expand the storage capacity of an RDS instance.You can expand the storage capacity of your RDS instance. For more information, see Change instance specifications.Note After the specifications of your RDS instance are changed, ApsaraDB RDS unlocks your RDS instance in approximately 5 minutes.
- Delete historical or unnecessary data.
- Use Data Management (DMS) to connect to your RDS instance. For more information, see Use DMS to log on to an ApsaraDB RDS for MySQL instance.
- On the SQL Console tab, execute the following statement to view the sizes of data files and identify the data files that contain historical data or unnecessary data:
SELECT file_name, concat(TOTAL_EXTENTS,'M') as 'FIle_size' FROM INFORMATION_SCHEMA.FILES order by TOTAL_EXTENTS DESC
- Execute the
DROP
orTRUNCATE
statement to delete historical or unnecessary data.Note After the deletion is complete, ApsaraDB RDS unlocks your RDS instance in approximately 5 minutes.- DROP: Execute the
DROP TABLE <Database name>.<Table name>
statement to delete a table. - TRUNCATE: Execute the
TRUNCATE TABLE <Database name>.<Table name>
statement to delete data records from a table.
- DROP: Execute the
What to do next
- Configure automatic storage expansion for the RDS instance. If the storage usage of the RDS instance reaches a threshold, ApsaraDB RDS automatically expands the storage capacity of the RDS instance. For more information, see Configure automatic storage expansion.
- If the
DELETE
statement is frequently executed on some tables, the tables become fragmented. In this case, execute theOPTIMIZE TABLE <Database name>.<Table name>
statement to reclaim storage during off-peak hours. For more information, see How do I use the OPTIMIZE TABLE statement to release the tablespace of an ApsaraDB RDS for MySQL instance?