# MySQL grows until it crashes

**URL:** <https://forums.percona.com/t/mysql-grows-until-it-crashes/875>\
**Category:** Other MySQL® Questions\
**Created:** [August 9, 2008, 3:04am UTC](https://forums.percona.com/t/mysql-grows-until-it-crashes/875 "2008-08-09T03:04:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![james](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@james](https://forums.percona.com/u/james)\
**Post date:** [August 9, 2008, 3:04am UTC](https://forums.percona.com/t/mysql-grows-until-it-crashes/875/1 "2008-08-09T03:04:31Z")

</div>

I have a 64-bit server (with 64-bit OS and MySQL) with 4 gigs of RAM and 2 gigs of swap. We run MySQL 5.0.22 (installed from the CentOS 5.0 RPM). Nothing else runs on the server.

We have a problem where MySQL eats up more and more RAM until it starts swapping, then it eats up the swap until the OS kills it because there is nothing left to be allocated. It takes weeks sometimes for it to creep to the limit, but performance drops over time as well, due to swapping.

The database is extremely write-heavy, uses InnoDB almost exclusively (some logs are stored in MyISAM), and is about 300 gigabytes in size (~90 billion rows total).

MySQL is configured as follows:

innodb\_additional\_mem\_pool\_size=20M  
innodb\_buffer\_pool\_size=2048M  
innodb\_file\_per\_table  
innodb\_flush\_log\_at\_trx\_commit=2  
innodb\_log\_buffer\_size=4M  
innodb\_log\_file\_size=512M  
innodb\_thread\_concurrency=8  
key\_buffer\_size=32M  
max-connect-errors=10000000  
table\_cache=1024  
thread\_cache=32  
transaction-isolation=READ-COMMITTED  
query\_cache\_size=32M  
read\_buffer\_size=2M  
sort\_buffer\_size=8M

MySQL has been up for about six days right now and is using 5770MB of memory. Even with shared libraries and other such memory use, I can’t figure out how it is using that much memory based on that configuration. How can I fix my configuration? Per the InnoDB tuning guide on the blog, I should be able to set the buffer pool size to be 70% of total RAM, which would cause MySQL to crash within hours.

I’d like to work on performance tuning, but as long as MySQL is crashing, I don’t know how I can.

I appreciate any help. I’m sure I’m missing something simple.

---

<div class="post-metadata">

**Author:** ![Speeple](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@Speeple](https://forums.percona.com/u/Speeple)\
**Post date:** [August 9, 2008, 8:25am UTC](https://forums.percona.com/t/mysql-grows-until-it-crashes/875/2 "2008-08-09T08:25:07Z")

</div>

How was MySQL installed? Compiled from source? What version?

Is that all there is to your config?

---

<div class="post-metadata">

**Author:** ![james](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@james](https://forums.percona.com/u/james)\
**Post date:** [August 9, 2008, 11:37am UTC](https://forums.percona.com/t/mysql-grows-until-it-crashes/875/3 "2008-08-09T11:37:09Z")

</div>

MySQL was installed using yum (for configuration management between a handful of servers, I’d rather not compile from source):

yum install mysql-server

It’s directly from the CentOS Extras.

That is the bulk of /etc/my.cnf. The whole file is as follows:

[mysqld]  
datadir=/var3/lib/mysql  
socket=/var/lib/mysql/mysql.sock  
old\_passwords=1

safe-show-database  
key\_buffer\_size=32M  
innodb\_buffer\_pool\_size=2048M  
innodb\_additional\_mem\_pool\_size=20M  
innodb\_log\_file\_size=512M  
innodb\_log\_buffer\_size=4M  
innodb\_file\_per\_table  
innodb\_flush\_log\_at\_trx\_commit=2  
innodb\_thread\_concurrency=8  
max-connect-errors=10000000  
table\_cache=1024  
thread\_cache=32  
transaction-isolation=READ-COMMITTED  
query\_cache\_size=32M  
read\_buffer\_size=2M  
server-id=3  
sort\_buffer\_size=8M

log-bin=/home/junk/mysql/mysql-bin

tmpdir=/var3/tmp

report-host=johnson.junk.ws

max\_connections=60

[mysql.server]  
user=mysql  
basedir=/var3/lib

[mysqld\_safe]  
log-error=/var/log/mysqld.log  
pid-file=/var/run/mysqld/mysqld.pid

---

<div class="post-metadata">

**Author:** ![Speeple](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@Speeple](https://forums.percona.com/u/Speeple)\
**Post date:** [August 10, 2008, 3:57am UTC](https://forums.percona.com/t/mysql-grows-until-it-crashes/875/4 "2008-08-10T03:57:23Z")

</div>

OK so it’s vanilla MySQL and the config looks fine.

50% for InnoDB is normal, and your per connection settings appear to be OK.

What kind of swappiness setting do you use?

[URL][An Interview With Linus Torvalds: Linux and Git - Part 1 | Tag1 Consulting](http://kerneltrap.org/node/3000%5B/URL%5D)

I honestly doubt the swappiness is the problem, it’s sounds like a residual memory leak due to something in your setup.

If it was me I’d be inclined to do a fresh OS install etc, but with 300 Gb that’s going to hurt.

---

<div class="post-metadata">

**Author:** ![james](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@james](https://forums.percona.com/u/james)\
**Post date:** [August 18, 2008, 9:59pm UTC](https://forums.percona.com/t/mysql-grows-until-it-crashes/875/5 "2008-08-18T21:59:37Z")

</div>

Yeah, I looked into the swappiness setting a long while ago. It’s set at the default (60) now. It doesn’t affect performance much since MySQL is the only thing running anyway.

We have the out of memory error come up because the server doesn’t have enough swap (we have 2 gigs of swap for 4 gigs of RAM, which isn’t ideal… if I had a chance to go back and smack the datacenter tech, I probably would). But even still, I just can’t figure out why MySQL is using so much RAM.

I guess I’ll just wait until December when we get new servers anyway. _sigh_ Maybe I’ll look into PostgreSQL )
