"What now?" issues every now and then with Magento are the norm, and I got this one a few days ago:
SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction, query was: INSERT INTO `catalog_product_index_eav_temp` SELECT DISTINCT [...]
Apparently the server went down for a second, or MySQL went down... or something happened and a reindex process was interrupted (in my case the one for the "Product EAV" index), and there was no way to make it work again.
Even the usual bin/magento indexer:reset
and then a manual reindex with bin/magento indexer:reindex
didn't do the trick and the only difference was that instead of the previous error I was getting the classic one:
Product EAV index is locked by another reindex process. Skipping.
Lucky me, I find this tweet by @willemwigman on Twitter that basically indicates that, when you have no way to "unlock" an index and after you already tried the reset and manual reindex, spot the lock
node within your app/etc/env.php
file and change the prefix
within the inner config
node.
<?php
return [
[...]
'lock' => [
'provider' => 'db',
'config' => [
'prefix' => 'new-prefix-here'
]
]
];
Reset the indexes and try to reindex again.
That alone should do the trick.