Solving cluster_block_exception Error in Magento 2: Index blocked by [TOO_MANY_REQUESTS/12/disk usage exceeded flood-stage watermark, index has read-only-allow-delete block]
In the world of Magento 2, encountering errors during routine operations like reindexing is not uncommon. One such error, the “cluster_block_exception,” can be particularly frustrating, especially when it disrupts critical tasks. Today, we delve into this issue, exploring solutions recommended by experts in the Magento community.
Understanding the Problem
The “cluster_block_exception” error arises in Magento 2 when Elasticsearch encounters a disk usage problem that exceeds the flood-stage watermark. This error puts Elasticsearch in a read-only mode, hindering essential operations like reindexing.
When this error appears, it usually has the following message:
{"error":{"root_cause":[{"type":"cluster_block_exception","reason":"index [magento2_product_1_v236] 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_v236] blocked by: [TOO_MANY_REQUESTS/12/disk usage exceeded flood-stage watermark, index has read-only-allow-delete block];"},"status":429}
Solution to fix cluster_block_exception error
As mentioned, Elasticsearch triggered an error due to low disk space, causing the system to go into read-only mode. To resolve this issue, follow these steps:
Step 1: Disable Cluster Routing Allocation Disk Threshold:
Run the following command in the Magento 2 root directory:
curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_cluster/settings -d '{ "transient": { "cluster.routing.allocation.disk.threshold_enabled": false } }'
Step 2: Remove read-only status:
Use the following command:
curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'
After completing the above 2 steps, you can now reindex without encountering this annoying error.
Conclusion
By following these recommended steps, you can effectively resolve the “cluster_block_exception” issue in Magento 2 and ensure smooth reindexing operations. Understanding the root cause of errors like these and implementing targeted solutions is crucial for maintaining a stable Magento 2 environment.