1
votes

I have a problem with restoring databases to an RDS instance. We have about 12 000 databases, and a bash script does the restore, 10 databases at a time. After every 500 hundred database, the script sleeps for a minute, and runs the following queries: RESET QUERY CACHE;FLUSH QUERY CACHE;FLUSH TABLES;, also there is a one second sleep after every database.

I am continuously running into problems with the RDS database, once the InnoDB files are corrupted (I guess just because of the failed restore attempts, I created a new instance, and it works well), or I get this error message:

2017-09-11 06:11:43 29836 [ERROR] /rdsdbbin/mysql/bin/mysqld: Out of memory (Needed 114240 bytes)
2017-09-11 06:11:43 29836 [ERROR] 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

After the error message, the DB instance restarts, and the restore fails. It says I should increase the ulimit, but I cannot do this on the Amazon RDS server, or even cannot add more swap space.

The database is a db.t2.medium, we would like to restore to test our daily backups and after the restoration, I obfuscate all user data and create statistics from it, so it should be fresh.

What would be the best solution to achieve this?

2
How big is each database? Are you doing anything with them besides the restore?stdunbar
12,000 databases is a large number of databases for such a small server, assuming even a small number of tables per database. The most sensible advice is to start much larger, and then scale the instance downward. If you insist on trying to use the small machine, change the formula for innodb_buffer_pool_size in the parameter group downward from {DBInstanceClassMemory*3/4} to {DBInstanceClassMemory*2/4} to free up some memory by making the buffer pool smaller -- that is not optimal, but you need more free memory and that's the only way to get it without scaling up.Michael - sqlbot
Also, make a dump file with --no-data and try restoring only the schemata, first, then go for the full backup. The FLUSH statements are unnecessary.Michael - sqlbot

2 Answers

1
votes

If you are running out of memory, up the database size from a t2.medium to something bigger

Try an r3, this has 15.25GiB compared with 4GiB on a t2.medium

0
votes

Like myself your most likely running into this recent RDS bug https://forums.aws.amazon.com/thread.jspa?threadID=251866&tstart=0