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

版本: 6.8-7.15

简而言之,当在 Elasticsearch 中对未处于正确状态的分片尝试执行操作时,会发生此错误。Elasticsearch 操作只能在分片状态为已启动(started)或已重定位(relocated)时执行。如果分片处于不正确的状态,例如正在初始化(initializing)、正在关闭(closing)或已关闭(closed),则无法执行操作。要解决此问题,您可以等待分片达到正确状态,或者手动更改分片状态。但是,手动更改分片状态应谨慎操作,因为这可能导致数据丢失或损坏。

日志上下文 #

日志 “operations only allowed when shard state is one of” 的类名是 IndexShard.java。 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人使用:

}  public void readAllowed() throws IllegalIndexShardStateException {
 IndexShardState state = this.state; // one time volatile read
 if (readAllowedStates.contains(state) == false) {
 throw new IllegalIndexShardStateException(shardId; state; "operations only allowed when shard state is one of " +
 readAllowedStates.toString());
 }
 }  /** returns true if the {@link IndexShardState} allows reading */