--- title: "恢复被取消原因原因 - 如何解决此 Elasticsearch 异常" date: 2026-03-02 lastmod: 2026-03-02 description: "当 Elasticsearch 分片的恢复过程由于特定原因被中断或停止时,会出现此错误。这可能是由于节点离开集群、新的恢复过程启动或手动取消导致的。" tags: ["恢复", "分片恢复", "异常处理"] summary: "版本: 6.8-8.9 简而言之,当 Elasticsearch 分片的恢复过程由于特定原因被中断或停止时,会出现此错误。这可能是由于节点离开集群、新的恢复过程启动或手动取消导致的。要解决此问题,您可以尝试重新启动恢复过程,确保集群的稳定性以防止节点意外离开,或检查可能导致取消的任何手动中断。 日志上下文 # 日志 “recovery was canceled reason [ " + reason + " ]” 的类名是 RecoverySourceHandler.java. 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人使用: cancellableThreads.setOnCancel((reason; beforeCancelEx) -> { final RuntimeException e; if (shard.state() == IndexShardState.CLOSED) { // check if the shard got closed on us e = new IndexShardClosedException(shard.shardId(); "shard is closed and recovery was canceled reason [" + reason + "]"); } else { e = new CancellableThreads." --- > **版本:** 6.8-8.9 简而言之,当 Elasticsearch 分片的恢复过程由于特定原因被中断或停止时,会出现此错误。这可能是由于节点离开集群、新的恢复过程启动或手动取消导致的。要解决此问题,您可以尝试重新启动恢复过程,确保集群的稳定性以防止节点意外离开,或检查可能导致取消的任何手动中断。 日志上下文 ----------- 日志 "recovery was canceled reason [ " + reason + " ]" 的类名是 [RecoverySourceHandler.java.](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人使用: ```java cancellableThreads.setOnCancel((reason; beforeCancelEx) -> { final RuntimeException e; if (shard.state() == IndexShardState.CLOSED) { // check if the shard got closed on us e = new IndexShardClosedException(shard.shardId(); "shard is closed and recovery was canceled reason [" + reason + "]"); } else { e = new CancellableThreads.ExecutionCancelledException("recovery was canceled reason [" + reason + "]"); } if (beforeCancelEx != null) { e.addSuppressed(beforeCancelEx); } IOUtils.closeWhileHandlingException(releaseResources; () -> future.onFailure(e)); ```