How to Unlock Reindex Process in Magento 2

Indexing and reindexing in Magento 2 is a common process. While the indexing process, we all face a common error many times. "index is locked by another reindex process. Skipping." is the error message displayed on your screen. The reasons behind this error are limited memory, connection timeout, other processes disruption, or fatal error. Moreover, it happens when the index type is locked and you are trying to reindex that. At that time, you are not allowed to reindex the certain locked index type. It will always skip when you try to reindex that locked index type. But not to worry. You can find a solution in our today's article on "How to unlock reindex process in Magento 2".

Email marketing is also very important to the business. While looking for other tools and software, update your email service by switching to Sendinblue or GetResponse to get a better sales conversation.

How to Unlock Reindex Process in Magento 2

Step 1: Reindex when Index is Locked

First, 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.

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

Step 2: Get Index Types Info

After that, run the below command to check the status of all index types.

php bin/magento indexer:status

You can check the output below after running the above command.

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 3: Check Index Types Status

Then, to check the status, run the below command first.

php bin/magento indexer:status

You will receive the result as per the following.

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

Now, we have to reset the index types which are locked to solve this issue. Run the below command to reset all index types.

php bin/magento indexer:reset

After that, if you want to reset multiple index types then, run this command.

php bin/magento indexer:reset IndexType1 IndexType2 IndexType3

In our case, we need to unlock only one index type which is cataloginventory_stock. To do that run the below command.

php bin/magento indexer:reset cataloginventory_stock

Here is the result you will get:

Stock indexer has been invalidated.

Step 5: Reindex Index Types

You need to check the indexer status again. To check that run this.

php bin/magento indexer:status

The output will be displayed as follows:

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 above result, you can see that the stock index is unlocked successfully. You can see the status is changed from "processing" to "reindex required".

Now, we need to reindex the stock index by running the following command.

php bin/magento indexer:reindex cataloginventory_stock

Here is the result after running the above command.

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

Final words

You just need to follow these steps one by one to unlock reindex process in Magento 2. This process in Magento 2 is mandatory to avoid the chances of another reindex process skipped to lock the index. Further, the above solution is very easy. You need to run the command, and it is all done. Always feel free to contact us regarding any Magento-related queries. Moreover, if you have any doubts about this article, add your questions and reviews in the comment or contact us.

Happy Coding!