elasticsearch config_error ai_generated true

PrimaryShardNotAllocatedException: primary shard [my_index][0] not allocated because node version [7.10.2] is incompatible with index version [7.17.0]

ID: elasticsearch/primary-shard-not-allocated-due-to-node-version-mismatch

Also available as: JSON · Markdown · 中文
85%Fix Rate
85%Confidence
1Evidence
2024-03-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
7.10.2 active
7.17.0 active
8.0.0 active

Root Cause

A node with an older Elasticsearch version cannot host a primary shard created by a newer version due to Lucene segment format incompatibility.

generic

中文

较旧版本的 Elasticsearch 节点无法托管由较新版本创建的主分片,因为 Lucene 段格式不兼容。

Official Documentation

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rolling-upgrades.html

Workarounds

  1. 90% success Upgrade the older node's Elasticsearch version to match the index version (e.g., from 7.10.2 to 7.17.0) using rolling upgrade: `sudo systemctl stop elasticsearch`, replace package, restart, and wait for shard allocation.
    Upgrade the older node's Elasticsearch version to match the index version (e.g., from 7.10.2 to 7.17.0) using rolling upgrade: `sudo systemctl stop elasticsearch`, replace package, restart, and wait for shard allocation.
  2. 80% success Reindex the data to a new index with compatible settings: `POST _reindex { "source": { "index": "my_index" }, "dest": { "index": "my_index_v2" } }` then delete old index and use alias.
    Reindex the data to a new index with compatible settings: `POST _reindex { "source": { "index": "my_index" }, "dest": { "index": "my_index_v2" } }` then delete old index and use alias.

中文步骤

  1. Upgrade the older node's Elasticsearch version to match the index version (e.g., from 7.10.2 to 7.17.0) using rolling upgrade: `sudo systemctl stop elasticsearch`, replace package, restart, and wait for shard allocation.
  2. Reindex the data to a new index with compatible settings: `POST _reindex { "source": { "index": "my_index" }, "dest": { "index": "my_index_v2" } }` then delete old index and use alias.

Dead Ends

Common approaches that don't work:

  1. 95% fail

    Node version does not change on restart; manual upgrade is required.

  2. 85% fail

    Data is lost and the root cause (version mismatch) remains if other nodes are still newer.