debugsqlMinor
Cannot ALTER TABLE
Viewed 0 times
cannotaltertable
Problem
I have a particular table that I cannot add a key for:
Googling the issue it seems that this problem is often either a configuration issue or a disk space issue. In fact, this database is running on an Amazon RDS instance, which means that it is basically a managed server dedicated to MySQL with a very standard configuration. Also, the disk allocated to us is only about 25% full.
Considering that perhaps there disk on the VM (powered by Xen I believe) is full, and not my allocated disk space which is likely not even in the same room (network storage), I rebooted the RDS instance in the hope that I would get a new instance on another VM. However, that did not help.
What should be my next troubleshooting step?
This is the table:
```
mysql> show create table tasks;
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table
mysql> ALTER TABLE tasks ADD KEY `fruitful_user_count` (`user_id`, `is_fruitful`);
ERROR 1034 (HY000): Incorrect key file for table 'tasks'; try to repair itGoogling the issue it seems that this problem is often either a configuration issue or a disk space issue. In fact, this database is running on an Amazon RDS instance, which means that it is basically a managed server dedicated to MySQL with a very standard configuration. Also, the disk allocated to us is only about 25% full.
Considering that perhaps there disk on the VM (powered by Xen I believe) is full, and not my allocated disk space which is likely not even in the same room (network storage), I rebooted the RDS instance in the hope that I would get a new instance on another VM. However, that did not help.
What should be my next troubleshooting step?
This is the table:
```
mysql> show create table tasks;
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table
Solution
Try to repair the table:
mysql> LOCK TABLES fruitful_user_count WRITE;
mysql> CREATE TABLE fruitful_user_count_new LIKE fruitful_user_count;
mysql> INSERT INTO fruitful_user_count_new SELECT * FROM fruitful_user_count;
mysql> RENAME TABLE fruitful_user_count TO fruitful_user_count_old;
mysql> RENAME TABLE fruitful_user_count_new TO fruitful_user_count;
mysql> UNLOCK TABLES;
Context
StackExchange Database Administrators Q#84607, answer score: 5
Revisions (0)
No revisions yet.