Bobcares

How to Fix the `cluster_block_exception` Error in Magento 2

PDF Header PDF Footer

Discover how to fix the `cluster_block_exception` error in Magento 2 during reindexing. Our Magento Support team is ready to assist with any queries or concerns.

How to Fix the `cluster_block_exception` Error in Magento 2 During Reindexing

Recently, one of our customers ran into the cluster_block_exception error while managing a Magento 2 store that uses Elasticsearch or OpenSearch as the search engine. This error is more prominent when running `catalogsearch_fulltext`.How to Fix the `cluster_block_exception` Error in Magento 2 During Reindexing

According to our Experts, this error usually happens because Elasticsearch enters a read-only mode to prevent data corruption when disk space runs dangerously low.

The `cluster_block_exception` in Magento 2 is not a bug. It is a protective feature of Elasticsearch designed to avoid data loss when disk space is critically low.

Today, we will explore why it occurs, how to fix it, and how to prevent it from happening again.

What Causes the `cluster_block_exception` in Magento 2?

The `cluster_block_exception` is triggered when Elasticsearch detects that disk usage exceeds its flood-stage watermark. This value is usually set to 95% by default. To safeguard data, Elasticsearch automatically switches indices to read-only-allow-delete mode, blocking all write operations, including reindexing.

  • Elasticsearch enforces the error when disk usage crosses the 95% threshold.
  • The read-only mode is a protective mechanism to prevent data loss or corruption.
  • Reindexing massive product catalogs can rapidly consume available disk space, triggering the issue.

This problem is especially frustrating when it happens alongside other Magento indexing or deployment errors. For example, if you’ve also encountered issues like a Magento 2 blank page with no error, disk space problems might be part of a broader system issue.

How to Fix the `cluster_block_exception` Error

Here are two reliable methods to resolve this error and restore your Magento 2 reindexing process:

Solution 1. Disable Disk Threshold and Remove Read-Only Status

If Elasticsearch has gone into read-only mode due to disk space constraints, follow these steps:

  1. First, run this command from your 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
    }
    }'
  2. Next, unlock the indices:

    curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{
    "index.blocks.read_only_allow_delete": null
    }'
  3. After running the above commands, proceed with:

    php bin/magento setup:upgrade
    php bin/magento setup:static-content:deploy
    php bin/magento indexer:reindex
    php bin/magento cache:clean

These commands are essential for restoring normal operations, especially when dealing with system changes or other Magento-specific tasks like disabling Magento 2 cron jobs during maintenance.

This will resolve the error and allow indexing to continue.

Solution 2. Free Up Disk Space and Adjust Watermark Settings

Method 1. Free Up Disk Space

Make sure at least 5% of the disk space is free. Once done, we need to manually unlock the indices:


curl -XPUT -H "Content-Type: application/json" https://[YOUR_ELASTICSEARCH_ENDPOINT]:9200/_all/_settings -d '{
"index.blocks.read_only_allow_delete": null
}'

Method 2. Adjust Elasticsearch Watermark Settings

Alternatively, we can configure Elasticsearch to use different disk usage thresholds. This gives us more control over when the system triggers protective actions:


curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_cluster/settings -d '{
"transient": {
"cluster.routing.allocation.disk.watermark.low": "100gb",
"cluster.routing.allocation.disk.watermark.high": "50gb",
"cluster.routing.allocation.disk.watermark.flood_stage": "10gb",
"cluster.info.update.interval": "1m"
}
}'

Even after adjusting the settings, we still need to remove the read-only block as shown in Method 1.

While the commands above will resolve the immediate issue, the root cause remains disk space exhaustion. For long-term stability:

  • Monitor disk usage regularly
  • Add storage capacity if needed
  • Schedule routine index optimizations to reduce disk overhead

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

By following the above steps, we can keep our Magento 2 environment stable and avoid interruptions during indexing operations.

In short, our Support Engineers demonstrated how to fix the `cluster_block_exception` error in Magento 2 during reindexing.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Get featured on the Bobcares blog and share your expertise with a global tech audience.

WRITE FOR US
server management

Spend time on your business, not on your servers.

TALK TO US

Or click here to learn more.

Speed issues driving customers away?
We’ve got your back!