Don't Generate an Index Setting History UUID unless it's Supported (#64164) (#64213)

In 7.x we can't just by default generate this setting as it might not be
supported by data nodes that are assigned shards for an older version in mixed version
clusters.

Closes #64152
This commit is contained in:
Armin Braun 2020-10-28 09:03:09 +01:00 committed by GitHub
parent 2492f48375
commit a697d5edae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 8 deletions

View File

@ -24,10 +24,6 @@ setup:
---
"Create a snapshot and then restore it":
- skip:
version: "all"
reason: "AwaitsFix https://github.com/elastic/elasticsearch/issues/64152"
- do:
snapshot.create:
repository: test_repo_restore_1

View File

@ -386,10 +386,17 @@ public class RestoreService implements ClusterStateApplier {
aliases.add(alias.value);
}
}
indexMdBuilder.settings(Settings.builder()
.put(snapshotIndexMetadata.getSettings())
.put(IndexMetadata.SETTING_INDEX_UUID, currentIndexMetadata.getIndexUUID())
.put(IndexMetadata.SETTING_HISTORY_UUID, UUIDs.randomBase64UUID()));
final Settings.Builder indexSettingsBuilder = Settings.builder()
.put(snapshotIndexMetadata.getSettings())
.put(IndexMetadata.SETTING_INDEX_UUID, currentIndexMetadata.getIndexUUID());
// Only add a restore uuid if either all nodes in the cluster support it (version >= 7.9) or if the
// index itself was created after 7.9 and thus won't be restored to a node that doesn't support the
// setting anyway
if (snapshotIndexMetadata.getCreationVersion().onOrAfter(Version.V_7_9_0) ||
currentState.nodes().getMinNodeVersion().onOrAfter(Version.V_7_9_0)) {
indexSettingsBuilder.put(SETTING_HISTORY_UUID, UUIDs.randomBase64UUID());
}
indexMdBuilder.settings(indexSettingsBuilder);
IndexMetadata updatedIndexMetadata = indexMdBuilder.index(renamedIndexName).build();
rtBuilder.addAsRestore(updatedIndexMetadata, recoverySource);
blocks.updateBlocks(updatedIndexMetadata);