Skip to content

Commit

Permalink
Fix Broken Snapshots in Mixed Clusters (elastic#48993) (elastic#48995)
Browse files Browse the repository at this point in the history
Reverts elastic#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 elastic#48983
  • Loading branch information
original-brownbear authored Nov 12, 2019
1 parent 1903505 commit 0e10352
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,6 @@ public List<IndexId> resolveNewIndices(final List<String> indicesToResolve) {
* 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,6 @@ private void cleanupAfterError(Exception exception) {
}

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));
Expand Down

0 comments on commit 0e10352

Please sign in to comment.