When I run my custom import script, and during it's execution starts reindex
, it causes the error :
SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction, query was:
INSERT INTO catalog_product_entity_datetime
... and othercatalog_product_entity_* tables
How can I avoid these errors?
I thinking about a few ways:
- Lock indexer
- Lock tables (bad idea)
- Temporary disable cron (even more bad idea)
- Extend and override core indexer and manually write the code that will check some lock files.
I can't find any information about indexer locking in Magento 2.
And another question: It can be a problem with the deadlock not at all in reindex and import?
Thanks.