What does "cleaning up" mean in MySQL InnoDB transaction status and how to prevent it? In our database (MySQL 5.6.22 on RDS) we have a lot of transactions (~500) in a state "cleaning up" under the load:

&gt; SHOW ENGINE innodb STATUS;
...
------------
TRANSACTIONS
------------
...
---TRANSACTION 70150348714, not started
MySQL thread id 132590, OS thread handle 0x2b2a712ca700, query id 10842420427 &lt;ip&gt; &lt;user&gt; 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.


https://dev.mysql.com/doc/refman/5.6/en/general-thread-states.html

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 &quot;cleaning up&quot; 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.
To quote the man himself:


  Hi!
  
  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