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

版本: 6.8-7.15

简而言之,此错误发生在 Elasticsearch 尝试将分片分配到节点时,但发现了与预期不同的分配 ID 或 term 值。这可能是由于网络分区、节点故障或手动干预造成的。要解决此问题,您可以尝试手动使用集群重新路由 API 重新路由分片,或者重启节点。如果问题持续存在,您可能需要从快照恢复数据或重新索引数据。在进行任何更改之前,请始终确保您的集群状态为绿色,以避免数据丢失。

日志上下文 #

日志 “expected allocation id [{}] with term [{}] but found [{}]” 的类名是 TransportReplicationAction.java。我们从 Elasticsearch 源代码中提取了以下内容,供那些需要深入了解上下文的人参考:

    throw new ShardNotFoundException(shardId, "expected allocation id [{}] but found [{}]",
    primaryRequest.getTargetAllocationID(), actualAllocationId);
}
final long actualTerm = indexShard.getPendingPrimaryTerm();
if (actualTerm != primaryRequest.getPrimaryTerm()) {
    throw new ShardNotFoundException(shardId, "expected allocation id [{}] with term [{}] but found [{}]",
    primaryRequest.getTargetAllocationID(), primaryRequest.getPrimaryTerm(), actualTerm);
}
acquirePrimaryOperationPermit(indexShard);