Hello Magento Friends,
Today I will give you the solution for the most common error, the reindex issue with Elasticsearch.
When there is a change in data in your database you need to run the reindex command to update the rows and columns. But when you run the below reindex command
1 |
bin/magento indexer:reindex |
An error is shown in the terminal as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
Design Config Grid index has been rebuilt successfully in 00:00:00 Customer Grid index has been rebuilt successfully in 00:00:05 Category Flat Data index has been rebuilt successfully in 00:00:00 Category Products index has been rebuilt successfully in 00:00:06 Product Categories index has been rebuilt successfully in 00:00:00 Catalog Rule Product index has been rebuilt successfully in 00:00:00 Product EAV index has been rebuilt successfully in 00:00:09 Stock index has been rebuilt successfully in 00:00:04 Inventory index has been rebuilt successfully in 00:00:00 Catalog Product Rule index has been rebuilt successfully in 00:00:00 Product Price index has been rebuilt successfully in 00:01:57 Google Product Removal Feed index has been rebuilt successfully in 00:00:00 Google Product Feed index has been rebuilt successfully in 00:00:00 Catalog Search index process unknown error: {"error":{"root_cause":[{"type":"cluster_block_exception","reason":"index [magento2_product_1_v1516] blocked by: [TOO_MANY_REQUESTS/12/disk usage exceeded flood-stage watermark, index has read-only-allow-delete block];"}],"type":"cluster_block_exception","reason":"index [magento2_product_1_v1516] blocked by: [TOO_MANY_REQUESTS/12/disk usage exceeded flood-stage watermark, index has read-only-allow-delete block];"},"status":429} |
This error means you do not have enough disk space to store or update data. The flood storage watermark is 95% default, so when it exceeds, the above error is shown and it puts the Elasticsearch into read-only mode. So you need to free up disk space or enlarge it.
Let’s get the solution for the above error in Magento 2.
Steps to Solve Reindex issue with Elasticsearch:
Step 1: From the terminal go to Magento Root path and run the below command:
1 |
curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_cluster/settings -d '{ "transient": { "cluster.routing.allocation.disk.threshold_enabled": false } }' |
1 |
curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}' |
Step 2: After this again run the reindex command in the terminal and check.
1 |
bin/magento indexer:reindex |
Conclusion:
This way you can solve the reindex error for Elasticsearch. If you face any difficulty, feel free to share with me via the comment box. Moreover, check out other related articles and solutions for reindexing in Magento 2.
- How to perform Reindexing Programmatically in Magento 2
- Magento 2: How to Flush the Cache and Reindex from Command Line
- How to Unlock Reindex Process in Magento 2
Share the solution with your fellow Magento developers to help them get rid of the error. See you with my next article till then stay in touch.
Happy Coding!
I have Magento2.4 with an elastic search version (7.9.2), Indexing of the catalogsearch_fulltext shows error
{“error”:{“root_cause”:[{“type”:”cluster_block_exception”,”reason”:”index [magen to2_product_1_v272] blocked by: [TOO_MANY_REQUESTS/12/disk usage exceeded flood- stage watermark, index has read-only-allow-delete block];”}],”type”:”cluster_block_exception”,”reason”:”index [magento2_product_1_v272] blocked by: [TOO_MANY_RE QUESTS/12/disk usage exceeded flood-stage watermark, index has read-only-allow-d elete block];”},”status”:429}
I tried running the following commands to free up.
– curl -XPUT -H “Content-Type: application/json” http://localhost:9200/_cluster/settings -d ‘{ “transient”: { “cluster.routing.allocation.disk.threshold_enabled”: false } }’
– curl -XPUT -H “Content-Type: application/json” http://localhost:9200/_all/_settings -d ‘{“index.blocks.read_only_allow_delete”: null}’
– sudo systemctl restart elasticsearch
and now if I run the index for the first time it works the second time again it shows the same error
sudo php bin/magento indexer:reindex catalogsearch_fulltext ;
I tried multiple times with free command facing the same issue.
Also executed.
sudo php bin/magento setup:upgrade;
sudo php bin/magento setup:di:compile;
sudo php bin/magento setup:static-content:deploy -f;
sudo php bin/magento indexer:reindex;
sudo php bin/magento cache:clean;
sudo php bin/magento cache:flush;
sudo chmod -R 0777 pub/;
sudo chmod -R 0777 var/;
sudo chmod -R 0777 generated/
Note: I have a stock update cron that runs each night, Around 200+updates will happen and I have scheduled the index of all products from save to schedule (Default 1 min cron).
This only happens at night, The clear command for elastic and restart I executed during the morning noticing the issue.
Since its showing TOO_MANY_REQUESTS how that’s being triggered. Is it from Magento or from Elasticsearch?
How to fix it? Please help.
You have to modify the code accordingly, so it executes faster and takes less time.
Worked! Thanks
I’ve recieve ab error in my terminal. Can you give me some suggestions about it, please?
curl: (7) Failed to connect to localhost port 9200: Connection refused
I have the same issue. Can anyone help us?
Please confirm what is your PORT for localhost, and change it accordingly.
Thanks for sharing, mate.
Why you are removing whole setting data ?
why not first check which index exist into elastic, if other than current prefix then remove it