In our database (MySQL 5.6.22 on RDS) we have a lot of transactions (~500) in a state "cleaning up" under the load:

---TRANSACTION 70150348714, not started
MySQL thread id 132590, OS thread handle 0x2b2a712ca700, query id 10842420427 <ip> <user> cleaning up

The only information I have found is:

The thread has processed one command and is preparing to free memory and reset certain state variables.


And this question comment mentions:

You may need to fine tune some memory related parameters if you see this often in your instance.

Many transactions are getting stuck in the "cleaning up" state - what could cause that?

What could be the actual problem? Why are so many transactions in "cleaning up" state? What memory parameters can I fine tune to prevent it?

Any advice will be greatly appreciated.

  • What are the slow queries in the slowlog? – Rick James Dec 4 '15 at 0:13

To quote the man himself:


Yes, you can get processes in the 'cleaning up' state if your table_cache is too small.

The general answer is that you should increase your table cache if the status variable 'opened_tables' tend to increase a lot over time.

Yours, Monty

Source: Grokbase.com


This could be caused by connection(s) that haven't been closed by the application. I've observed for some open connections SHOW ENGINE INNODB STATUS reports "cleaning up" but SHOW FULL PROCESSLIST reports the transaction as sleeping.

I've seen open connections with "cleaning up" status in 5.6 and 5.7.

You should check the application is closing all its MySQL connections.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.