I'm working on a Magento shop where we have some stability issue. From time to time, the Percona 5.7 database hits the "too many connections" limit and the shop becomes unresponsive. SHOW processlist seems to reveal that the issue is caused by a lot of query stuck Waiting for table metadata lock on this query: SELECT cataloginventory_stock_status.product_id, cataloginventory_stock_status.stock_status.

The server has active visitors, but it's by no mean under heavy load.

max_connection is set to 1024 (verified via show variables like '%connections%';)

This is the full output of processlist

Any hint is welcome, thanks.

1 Answer 1


To avoid lock, you should use READ COMMITTED transaction isolation level.

It's seems that you are importing stocks and reindexing data in the same time, you can also change scheduling.

I can tell you that with this request :

ALTER TABLE `cataloginventory_stock_status` DISABLE KEYS

You can check this Github issue for answer

  • Will try read committed, thanks. Could you please what male you think that import stock an reindex are running at The same time? Mar 28, 2017 at 19:03
  • Check edited answer
    – Aurélien
    Mar 29, 2017 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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