When I run my custom import script, and during it's execution starts reindex, it causes the error :


INSERT INTO catalog_product_entity_datetime ... and other catalog_product_entity_* tables

How can I avoid these errors?

I thinking about a few ways:

  1. Lock indexer
  2. Lock tables (bad idea)
  3. Temporary disable cron (even more bad idea)
  4. 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?



Here is the code which might help you (I took it from \Magento\Indexer\Model\Indexer::reindexAll):

$state = $stateFactory->create();
|improve this answer|||||

Your Answer

