How to Fix Index Read Only Error in Elasticsearch Quickly
read_only_allow_delete due to disk watermark limits. To fix it, remove this block by running PUT /your_index/_settings { "index.blocks.read_only_allow_delete": false }. This unlocks the index for writes again.Why This Happens
Elasticsearch sets an index to read-only mode automatically when the disk usage on the node reaches a high watermark. This is to protect the cluster from running out of disk space. The index gets a setting called index.blocks.read_only_allow_delete set to true, which blocks write operations but allows deletes.
This happens without manual intervention when disk space is low.
PUT /my_index/_doc/1 { "field": "value" }
The Fix
To fix the read only error, you need to remove the read-only block from the index settings. This allows Elasticsearch to accept write operations again.
Run this command replacing your_index with your actual index name:
PUT /your_index/_settings
{
"index.blocks.read_only_allow_delete": false
}Prevention
To avoid this error in the future, monitor your disk space regularly and keep it below the high watermark threshold (default 90%). You can also adjust the watermark settings if needed.
- Set up alerts for disk usage.
- Increase disk capacity or clean up old data.
- Adjust Elasticsearch watermarks in
elasticsearch.ymlif your environment requires.
Related Errors
Other similar errors include:
- Cluster Block Exception: Happens when the cluster is in read-only mode due to other reasons like snapshot in progress.
- Disk Full Errors: Write operations fail because the disk is completely full.
Quick fixes usually involve freeing disk space and removing blocks from affected indices.