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

版本: 6.8-7.4

简而言之,当尝试在 Elasticsearch 引擎处于恢复模式时执行 syncFlush 操作时,就会发生此错误。SyncFlush 是一个有助于在分片变为非活动状态时减少恢复时间的过程。但是,它不能在恢复期间执行。

要解决此问题,您可以:

  1. 等待恢复过程完成后再启动 syncFlush
  2. 手动停止恢复过程,执行 syncFlush,然后恢复恢复过程

但是,应谨慎使用后一种选项,因为它可能导致数据丢失。

日志上下文 #

日志 “syncFlush is only allowed if the engine is not recovery” 的类名是 IndexShard.java。我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考:

public Engine.SyncedFlushResult syncFlush(String syncId, Engine.CommitId expectedCommitId) {
    verifyNotClosed();
    logger.trace("trying to sync flush. sync id [{}], expected commit id [{}]]", syncId, expectedCommitId);
    Engine engine = getEngine();
    if (engine.isRecovering()) {
        throw new IllegalIndexShardStateException(shardId(), state, "syncFlush is only allowed if the engine is not recovery" +
        " from translog");
    }
    return engine.syncFlush(syncId, expectedCommitId);
}