Browse Source

Fix ShardGenerations in RepositoryData in BwC Case (#48920)

We were tripping the assertion that the makes sure we only have empty `ShardGenerations` in `RepositoryData` in the BwC case because shard generations were passed to the `Repository` in the BwC case. Fixed by only generating empty shard gen for BwC snapshots in `SnapshotsService`.
Armin Braun 6 years ago
parent
commit
13fc45d37f

+ 3 - 0
server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java

@@ -581,6 +581,9 @@ 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));