--- title: "无法关闭正在进行快照的索引 - 如何解决此 Elasticsearch 异常" date: 2026-03-29 lastmod: 2026-03-29 description: "当尝试关闭 Elasticsearch 中正在进行快照的索引时会出现此错误。快照过程需要索引保持打开状态才能成功完成。解决方法是等待快照完成或取消正在运行的快照过程。" tags: ["索引关闭", "快照", "异常处理", "数据备份", "集群管理"] summary: "版本: 6.8-7.15 简要来说,当您尝试关闭 Elasticsearch 中正在进行快照的索引时,会出现此错误。快照过程需要索引保持打开状态才能成功完成。要解决此问题,您可以等待快照过程完成后再关闭索引,或者如果快照不再需要,可以手动停止快照过程。请注意,停止快照过程可能会导致快照不完整。 日志上下文 # 日志 “Cannot close indices that are being snapshotted:” 的类名是 MetadataIndexStateService.java。 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人使用: } // 检查索引关闭是否与任何正在运行的快照冲突 Set<String> snapshottingIndices = SnapshotsService.snapshottingIndices(currentState, indicesToClose); if (snapshottingIndices.isEmpty() == false) { throw new SnapshotInProgressException("Cannot close indices that are being snapshotted: " + snapshottingIndices + ". Try again after snapshot finishes or cancel the currently running snapshot."); } final ClusterBlocks.Builder blocks = ClusterBlocks.builder().blocks(currentState.blocks()); final RoutingTable.Builder routingTable = RoutingTable." --- > **版本:** 6.8-7.15 简要来说,当您尝试关闭 Elasticsearch 中正在进行快照的索引时,会出现此错误。快照过程需要索引保持打开状态才能成功完成。要解决此问题,您可以等待快照过程完成后再关闭索引,或者如果快照不再需要,可以手动停止快照过程。请注意,停止快照过程可能会导致快照不完整。 ## 日志上下文 日志 "Cannot close indices that are being snapshotted:" 的类名是 [MetadataIndexStateService.java。](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人使用: ```java } // 检查索引关闭是否与任何正在运行的快照冲突 Set snapshottingIndices = SnapshotsService.snapshottingIndices(currentState, indicesToClose); if (snapshottingIndices.isEmpty() == false) { throw new SnapshotInProgressException("Cannot close indices that are being snapshotted: " + snapshottingIndices + ". Try again after snapshot finishes or cancel the currently running snapshot."); } final ClusterBlocks.Builder blocks = ClusterBlocks.builder().blocks(currentState.blocks()); final RoutingTable.Builder routingTable = RoutingTable.builder(currentState.routingTable()); ```