Help Center> Relational Database Service> Troubleshooting> RDS for MySQL> Performance Issues> DB Instance Becoming Read-Only Due to Insufficient Storage
Updated on 2023-11-03 GMT+08:00

DB Instance Becoming Read-Only Due to Insufficient Storage

Scenario

The following error is displayed for an RDS for MySQL instance:

The MySQL server is running with the --read-only option so it cannot execute this statement

Troubleshooting

  1. Go to the instance details page and check whether the storage is full.

  2. Log in to the database and check the read_only variable.

    show variables like 'read_only';

  3. From the previous steps, you can find that the storage space is full and the instance status has changed to read-only. As a result, the SQL statement fails to be executed.
  4. Check disk space distribution on the Storage Analysis page. For details, see Storage Analysis.
    Figure 1 Disk space distribution

Solution

  1. For insufficient storage caused by increased workload data, scale up storage space.

    If the original storage has reached the maximum, upgrade the specifications first.

    For instances using cloud disks, you can configure autoscaling so that RDS can autoscale your storage when the storage usage reaches the specified threshold.

  2. If too much data is stored, delete unnecessary historical data.
    1. If the instance becomes read-only, you need to contact customer service to cancel the read-only status first.
    2. Check the top 50 databases and tables with large physical files and identify the historical table data that can be deleted. For details, see Storage Analysis.
    3. To clear up space, you can optimize tables with a high fragmentation rate during off-peak hours.

      To delete data of an entire table, run DROP or TRUNCATE. To delete part of table data, run DELETE and OPTIMIZE TABLE.

  3. If binlog files occupy too much space, clear local binlogs.
  4. If temporary files generated by sorting queries occupy too much storage space, optimize your SQL statements.

    You can query slow query logs and top SQL statements, and analyze and optimize the problematic SQL statements.

  5. Subscribe to daily health reports to obtain SQL and performance analysis results, including slow SQL analysis, all SQL analysis, performance & storage analysis, and performance metric trend charts. You can receive a diagnosis report if there are any risks detected.

    For details, see Daily Reports.