Skip to content

Commit e6505a9

Browse files
Don't Generate an Index Setting History UUID unless it's Supported (#64164)
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
1 parent 261c8af commit e6505a9

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

rest-api-spec/src/main/resources/rest-api-spec/test/snapshot.restore/10_basic.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ setup:
2424
---
2525
"Create a snapshot and then restore it":
2626

27-
- skip:
28-
version: "all"
29-
reason: "AwaitsFix https://github.com/elastic/elasticsearch/issues/64152"
30-
3127
- do:
3228
snapshot.create:
3329
repository: test_repo_restore_1

server/src/main/java/org/elasticsearch/snapshots/RestoreService.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,17 @@ public ClusterState execute(ClusterState currentState) {
386386
aliases.add(alias.value);
387387
}
388388
}
389-
indexMdBuilder.settings(Settings.builder()
390-
.put(snapshotIndexMetadata.getSettings())
391-
.put(IndexMetadata.SETTING_INDEX_UUID, currentIndexMetadata.getIndexUUID())
392-
.put(IndexMetadata.SETTING_HISTORY_UUID, UUIDs.randomBase64UUID()));
389+
final Settings.Builder indexSettingsBuilder = Settings.builder()
390+
.put(snapshotIndexMetadata.getSettings())
391+
.put(IndexMetadata.SETTING_INDEX_UUID, currentIndexMetadata.getIndexUUID());
392+
// Only add a restore uuid if either all nodes in the cluster support it (version >= 7.9) or if the
393+
// index itself was created after 7.9 and thus won't be restored to a node that doesn't support the
394+
// setting anyway
395+
if (snapshotIndexMetadata.getCreationVersion().onOrAfter(Version.V_7_9_0) ||
396+
currentState.nodes().getMinNodeVersion().onOrAfter(Version.V_7_9_0)) {
397+
indexSettingsBuilder.put(SETTING_HISTORY_UUID, UUIDs.randomBase64UUID());
398+
}
399+
indexMdBuilder.settings(indexSettingsBuilder);
393400
IndexMetadata updatedIndexMetadata = indexMdBuilder.index(renamedIndexName).build();
394401
rtBuilder.addAsRestore(updatedIndexMetadata, recoverySource);
395402
blocks.updateBlocks(updatedIndexMetadata);

0 commit comments

Comments
 (0)