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
This commit is contained in:
Armin Braun 2019-11-12 21:35:41 +01:00 committed by GitHub
parent 1903505a3f
commit 0e1035241d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 6 deletions

View File

@ -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);

View File

@ -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<String, IndexId> indexLookup = new HashMap<>();
snapshot.indices().forEach(idx -> indexLookup.put(idx.getName(), idx));