📣 极限科技诚招搜索运维工程师(Elasticsearch/Easysearch)- 全职/北京 👉 : 立即申请加入

版本: 6.8-7.15

简而言之,当 Elasticsearch 尝试将分片移动到节点时,但该分片已被标记为已重定位,就会发生此错误。这通常由于网络问题或节点故障导致。要解决此问题,可以尝试重启 Elasticsearch 节点,或使用集群重路由 API 手动重新路由分片。如果问题持续存在,建议检查网络配置或节点的健康状况。

日志上下文 #

日志"Shard is marked as relocated; cannot safely move to state"的类名为 IndexShard.java。 我们从 Elasticsearch 源代码中提取了以下内容,供寻求深入上下文的用户参考:

} else if (currentRouting.primary() && currentRouting.relocating() && replicationTracker.isRelocated() &&
 (newRouting.relocating() == false || newRouting.equalsIgnoringMetadata(currentRouting) == false)) {
 // if the shard is not in primary mode anymore (after primary relocation) we have to fail when any changes in shard
 // routing occur (e.g. due to recovery failure / cancellation). The reason is that at the moment we cannot safely
 // reactivate primary mode without risking two active primaries.
 throw new IndexShardRelocatedException(shardId(); "Shard is marked as relocated; cannot safely move to state " +
 newRouting.state());
 }
 assert newRouting.active() == false || state == IndexShardState.STARTED || state == IndexShardState.CLOSED :
 "routing is active; but local shard state isn't. routing: " + newRouting + "; local state: " + state;
 persistMetadata(path; indexSettings; newRouting; currentRouting; logger);