diff --git a/server/src/main/java/org/opensearch/cluster/metadata/IndexMetadata.java b/server/src/main/java/org/opensearch/cluster/metadata/IndexMetadata.java index 26e9696188683..fe9527c144a13 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/IndexMetadata.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/IndexMetadata.java @@ -1844,11 +1844,15 @@ public static IndexMetadata fromXContent(XContentParser parser) throws IOExcepti // Reference: // https://github.com/opensearch-project/OpenSearch/blob/4dde0f2a3b445b2fc61dab29c5a2178967f4a3e3/server/src/main/java/org/opensearch/cluster/metadata/IndexMetadata.java#L1620-L1628 Version legacyVersion = LegacyESVersion.fromId(6050099); - if (Assertions.ENABLED && Version.indexCreated(builder.settings).onOrAfter(legacyVersion)) { + Version indexCreatedVersion = Version.indexCreated(builder.settings); + if (Assertions.ENABLED && indexCreatedVersion.onOrAfter(legacyVersion)) { assert mappingVersion : "mapping version should be present for indices"; assert settingsVersion : "settings version should be present for indices"; } - if (Assertions.ENABLED) { + // Reference: + // https://github.com/opensearch-project/OpenSearch/blob/2e4b27b243d8bd2c515f66cf86c6d1d6a601307f/server/src/main/java/org/opensearch/cluster/metadata/IndexMetadata.java#L1824 + legacyVersion = LegacyESVersion.fromId(7020099); + if (Assertions.ENABLED && indexCreatedVersion.onOrAfter(legacyVersion)) { assert aliasesVersion : "aliases version should be present for indices"; } return builder.build(); diff --git a/server/src/main/java/org/opensearch/repositories/IndexMetaDataGenerations.java b/server/src/main/java/org/opensearch/repositories/IndexMetaDataGenerations.java index e8f96bb313dd1..25cb0eaf43455 100644 --- a/server/src/main/java/org/opensearch/repositories/IndexMetaDataGenerations.java +++ b/server/src/main/java/org/opensearch/repositories/IndexMetaDataGenerations.java @@ -92,7 +92,9 @@ public String getIndexMetaBlobId(String metaIdentifier) { } /** - * Get the blob id by {@link SnapshotId} and {@link IndexId}. + * Get the blob id by {@link SnapshotId} and {@link IndexId}. If none is found, we fall back to the value + * of {@link SnapshotId#getUUID()} to allow for extended backwards compatibility use-cases with + * {@link org.opensearch.LegacyESVersion} versions which used the snapshot UUID as the index metadata blob id. * * @param snapshotId Snapshot Id * @param indexId Index Id @@ -100,7 +102,11 @@ public String getIndexMetaBlobId(String metaIdentifier) { */ public String indexMetaBlobId(SnapshotId snapshotId, IndexId indexId) { final String identifier = lookup.getOrDefault(snapshotId, Collections.emptyMap()).get(indexId); - return identifiers.get(identifier); + if (identifier == null) { + return snapshotId.getUUID(); + } else { + return identifiers.get(identifier); + } } /**