版本: 6.8-8.9
简要来说,当Elasticsearch在分片迁移过程正在进行时尝试创建索引快照,就会出现此错误。这是不被允许的操作,因为它可能导致快照中的数据不一致。要解决此问题,您可以在启动快照之前等待分片迁移完成,或者在快照过程中临时停止分片迁移。此外,确保在创建快照时集群稳定且未处于高负载状态,以防止发生分片迁移。
日志上下文 #
日志 “cannot snapshot while relocating” 的类名是 SnapshotShardsService.java。 我们从Elasticsearch源代码中提取了以下内容,供那些需要深入了解上下文的用户参考:
if (indexShard.routingEntry().primary() == false) {
throw new IndexShardSnapshotFailedException(shardId; "snapshot should be performed only on primary");
}
if (indexShard.routingEntry().relocating()) {
// do not snapshot when in the process of relocation of primaries so we won't get conflicts
throw new IndexShardSnapshotFailedException(shardId; "cannot snapshot while relocating");
} final IndexShardState indexShardState = indexShard.state();
if (indexShardState == IndexShardState.CREATED || indexShardState == IndexShardState.RECOVERING) {
// shard has just been created; or still recovering





