From 0e1035241da241e2c8611fa03ffe982142e8a47f Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Tue, 12 Nov 2019 21:35:41 +0100 Subject: [PATCH] Fix Broken Snapshots in Mixed Clusters (#48993) (#48995) Reverts #48947 and fixes the issue orginally addressed by removing the assertion. It turns out we can't simply pass empty shard generations to the snapshot finalization in the BwC case as that results in no indices being added to the meta for the given snapshot since we take the indices from the shard generations (even in the BwC case the `null` generations work fine for this). Closes #48983 --- .../java/org/elasticsearch/repositories/RepositoryData.java | 3 --- .../java/org/elasticsearch/snapshots/SnapshotsService.java | 3 --- 2 files changed, 6 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/repositories/RepositoryData.java b/server/src/main/java/org/elasticsearch/repositories/RepositoryData.java index 8589d2efdfc..20dcdc23718 100644 --- a/server/src/main/java/org/elasticsearch/repositories/RepositoryData.java +++ b/server/src/main/java/org/elasticsearch/repositories/RepositoryData.java @@ -315,9 +315,6 @@ public final class RepositoryData { * Writes the snapshots metadata and the related indices metadata to x-content. */ public XContentBuilder snapshotsToXContent(final XContentBuilder builder, final boolean shouldWriteShardGens) throws IOException { - assert shouldWriteShardGens || shardGenerations.indices().isEmpty() : - "Should not build shard generations in BwC mode but saw generations [" + shardGenerations + "]"; - builder.startObject(); // write the snapshots list builder.startArray(SNAPSHOTS); diff --git a/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java b/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java index 84e4a58545a..bfc3319ada1 100644 --- a/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java +++ b/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java @@ -594,9 +594,6 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus } private static ShardGenerations buildGenerations(SnapshotsInProgress.Entry snapshot) { - if (snapshot.useShardGenerations() == false) { - return ShardGenerations.EMPTY; - } ShardGenerations.Builder builder = ShardGenerations.builder(); final Map indexLookup = new HashMap<>(); snapshot.indices().forEach(idx -> indexLookup.put(idx.getName(), idx));