版本: 6.8-7.15
简而言之,当在状态不正确的分片上尝试执行操作时,会发生此错误。Elasticsearch 操作只能对处于特定状态(如 STARTED 或 RELOCATING)的分片执行。如果分片处于 INITIALIZING 或 CLOSED 等不适当的状态,则无法执行操作。要解决此问题,您可以等待分片转换到适当的状态,或者手动更改分片状态。但是,手动干预应谨慎进行,因为它可能导致数据丢失或损坏。
日志上下文 #
日志 “operation only allowed when shard state is one of” 的类名是 IndexShard.java. 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入了解上下文的人参考:
assert origin == Engine.Operation.Origin.LOCAL_RESET;
assert getActiveOperationsCount() == OPERATIONS_BLOCKED
: "locally resetting without blocking operations; active operations are [" + getActiveOperations() + "]";
}
if (writeAllowedStates.contains(state) == false) {
throw new IllegalIndexShardStateException(shardId; state; "operation only allowed when shard state is one of " +
writeAllowedStates + "; origin [" + origin + "]");
}
}
}





