How to Unlock Reindex Process in Magento 2: Index is locked by another reindex process Skipping?

During the indexing process, we often face a common issue many times, which is one type of error message saying- “Index is locked by another reindex process. Skipping.”

It happens when the index type is locked and you are trying to reindex that certain index type, as you will not be able to reindex the locked index type. It will always be skipped when you try to reindex that index type, which is locked.

To overcome this problem, you need to follow the below steps:


If the Stock index type is locked, you can reindex all the data by running the below command:

php bin/magento indexer:reindex

Now you will see that the Stock process has been skipped in the output below:

Design Config Grid index has been rebuilt successfully in 00:00:04
Customer Grid index has been rebuilt successfully in 00:00:06
Category Products index has been rebuilt successfully in 00:00:02
Product Categories index has been rebuilt successfully in 00:00:00
Product Price index has been rebuilt successfully in 00:00:01
Product EAV index has been rebuilt successfully in 00:00:00
Catalog Search index has been rebuilt successfully in 00:00:04
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

Now, let’s get started on how to Unlock Reindex Process when the index is locked by another reindex process Skipping with step by step guide.

Steps to unlock reindex process in Magento 2:

 

Step 1: Get Index Types Info

 

First of all, you need to do is- gather each index types’ detail presented in Magento 2.

To do so, use the below command:

php bin/magento indexer:info

Once you have run the command successfully, the result will be shown as:

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

From the above, it can be seen that the code for index type Stock is cataloginventory_stock.

 

Step 2: Check Index Types Status

 

Here you have to check the status of all the index types by running the command below:

php bin/magento indexer:status

Once you have run the command, you will see the status of the index type Processing Stock is Locked.

The detailed output can be found here.

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: Reset Index Types

 

Resetting all the locked index types is the perfect solution in order to resolve this problem.

To reset all index types, use the below command:

php bin/magento indexer:reset

Now you can reset multiple index types using the command below:

php bin/magento indexer:reset IndexType1 IndexType2 IndexType3

There’s only one index type locked in this case, notably “cataloginventory_stock”. Thus, you need to run the below command to unlock it.

php bin/magento indexer:reset cataloginventory_stock

After running the above command, you will receive the following result:

Stock indexer has been invalidated.

Step 4: Reindex Index Types

 

Now that you have to do is to check the indexer status one more time.

To check the indexer status, use the below command:

php bin/magento indexer:status

The result will be shown as:

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

In the result, you can see the Stock index type has been unlocked. I addition to this, you can also see the status, which has been changed to Reindex required from Processing.

Now, you can reindex the Stock index type using the below command:

php bin/magento indexer:reindex cataloginventory_stock

And the end result will be shown as:

Stock index has been rebuilt successfully in 00:00:04

Thus, following the above steps, you can easily unlock Reindex Process in Magento 2 and prevent another reindex process Skipping to lock the index type.

 

Categories: Tech Questions