Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS RDS out of memory error when adding column

We got MySQL database on AWS RDS with innodb engine, the MySQL version is 5.6.19.

When trying to add a column in a table, we get the error message below:

ERROR 1041 (HY000): Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space

The script we run to alter table is below: ALTER TABLE mytablename ADD COLUMN temp_colume varchar(255) NULL AFTER temp_firstcolumn;

Our RDS is on db.m3.2xlarge with 30GB memory: Our innodb buffer size is DBInstanceClassMemory*3/4 ~= 24GB

We can successfully re-creating the table with the column changes already made to it, but we are getting error when altering tables.

Does anyone meet the same issue?

like image 900
I.83 Avatar asked May 20 '16 07:05

I.83


People also ask

How do you increase Freeable memory on RDS?

If your freeable memory remains consistently low, you can change your RDS DB instance size to a larger instance size that has more memory. To monitor swap memory, turn on Enhanced Monitoring to review metrics in intervals with a granularity of as little as one second.

What happens when RDS runs out of space?

An Amazon RDS DB instance in the storage-full status doesn't have enough available space to perform basic operations, such as connecting to or restarting the instance. To resolve this issue, do the following: Confirm that the DB instance status is storage-full. Increase the allocated storage of your DB instance.


1 Answers

I've seen inplace alters in RDS fail lately. AWS support recommended modifying the alter table statement to look like this:

ALTER TABLE tbl ADD COLUMN abc varchar(123) AFTER zyx, ALGORITHM=COPY

The secret is to add

, ALGORITHM=COPY

to the end as a work around.

You could also failover the RDS instance https://dev.mysql.com/doc/refman/5.7/en/alter-table.html

like image 155
Cory Thorson Avatar answered Sep 22 '22 17:09

Cory Thorson