How to Unlock Reindex Process in Magento 2



Magento is a feature-rich eCommerce platform, built on open-source technology providing unparalleled flexibility and control to online merchants over the look, content, and functionality of their eCommerce store. Magento gives the power to merchant by providing intuitive Admin features powerful marketing, search engine optimization, and catalog management tools. This is one the reason Magento is renowned platform for ecommerce. Merchants prefer Magento to create sites that are tailored to their unique business needs.
Indexing in Magento is data transformation such as products, categories, and so on, to improve the performance of your e-store. Reindexing or updating is the transformed data, as data changes. Magento has well-structured architecture storing merchant data (including catalog data, stores, users, prices, and so on) in many database tables. To optimize storefront performance, Magento assembles data into special tables using indexers.
But sometimes a condition occurs when indexing process gets locked at the time of reindexing. When the process or the index type is locked then that particular locked index type cannot be reindex. That index type will be skipped in reindex process.
For example, let us assume that the Stock index type is locked. Then, when you try to reindex all data, you will get the following output result.

Design Config Grid index has been rebuilt successfully in 00:00:02
Customer Grid index has been rebuilt successfully in 00:00:03
Category Products index has been rebuilt successfully in 00:00:00
Product Categories index has been rebuilt successfully in 00:00:00
Product Price index has been rebuilt successfully in 00:00:00
Product EAV index has been rebuilt successfully in 00:00:00
Stock index is locked by another reindex process. Skipping.
Catalog Rule Product index has been rebuilt successfully in 00:00:00
Catalog Product Rule index has been rebuilt successfully in 00:00:00
Catalog Search index has been rebuilt successfully in 00:00:06

All other index types are reindexed successfully except Stock Index which is being locked. This blog shows how you can unlock the locked reindexing process in Magento 2 within few steps. 

Step-1
You can reset the indexer through command line with indexer:reset command.
Fetch the list of indexes name through command line: php bin/magento indexer:info
Output will be –

design_config_grid                       Design Config Grid
customer_grid                            Customer Grid
catalog_category_product                 Category Products
catalog_product_category                 Product Categories
catalog_product_price                    Product Price
catalog_product_attribute                Product EAV
catalogsearch_fulltext                   Catalog Search
cataloginventory_stock                   Stock
catalogrule_rule                         Catalog Rule Product
catalogrule_product                      Catalog Product Rule

Step-2
Fetch the list of index status through command line: php bin/magento indexer:status
Output will be -

Design Config Grid:                                Ready
Customer Grid:                                     Ready
Category Products:                                 Ready
Product Categories:                                Ready
Product Price:                                     Ready
Product EAV:                                       Ready
Catalog Search:                                    Ready
Stock:                                             Processing
Catalog Rule Product:                              Ready
Catalog Product Rule:                              Ready

Step-3
Finally, reset all the indexes through following command: php bin/magento indexer:reset
Output will be –

Design Config Grid indexer has been invalidated.
Customer Grid indexer has been invalidated.
Category Products indexer has been invalidated.
Product Categories indexer has been invalidated.
Catalog Rule Product indexer has been invalidated.
Product EAV indexer has been invalidated.
Stock indexer has been invalidated.
Product Price indexer has been invalidated.
Catalog Product Rule indexer has been invalidated.
Catalog Search indexer has been invalidated

Or you can reset the particular index (e.g. cataloginventory_stock) by running the following command:
php bin/magento indexer:reset cataloginventory_stock

By running the above commands output will be –
Stock indexer has been invalidated.

Result
Now, again check the indexer status: php bin/magento indexer:status
Output will be – 

As we can see, the Stock index type has been unlocked. Its status has been changed from “Processing” to “Reindex required”. Now, you can reindex it with the following command:

php bin/magento indexer:reindex

By running the above command it will reindex like all other index types. Hope this solution works for you.
If your indexer is locked by another process, don’t get nervous, there is a simple way to invalidate your indexes and run a full reindex again. Follow the above steps in sequence and unlock the reindex process. Have more ideas than drop us a comment. Looking for best Magento2 services for your ecommerce store contact us now.

Comments