Skip to content

Commit 351a410

Browse files
authored
Increment version on system index settings change (elastic#84994)
The test was failing on assertion around index settings version change in case actual settings were changed. This change adds missing version increment and readable messages to the related assertions.
1 parent 91379ea commit 351a410

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

server/src/main/java/org/elasticsearch/cluster/metadata/SystemIndexMetadataUpgradeService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public ClusterState execute(ClusterState currentState) throws Exception {
104104
boolean isHidden = indexMetadata.getSettings().getAsBoolean(IndexMetadata.SETTING_INDEX_HIDDEN, false);
105105
if (isSystem && isHidden == false) {
106106
builder.settings(Settings.builder().put(indexMetadata.getSettings()).put(IndexMetadata.SETTING_INDEX_HIDDEN, true));
107+
builder.settingsVersion(builder.settingsVersion() + 1);
107108
updated = true;
108109
}
109110
if (isSystem && indexMetadata.getAliases().values().stream().anyMatch(a -> Boolean.FALSE.equals(a.isHidden()))) {

server/src/main/java/org/elasticsearch/index/IndexService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,9 +784,9 @@ public synchronized void updateMetadata(final IndexMetadata currentIndexMetadata
784784
final long currentSettingsVersion = currentIndexMetadata.getSettingsVersion();
785785
final long newSettingsVersion = newIndexMetadata.getSettingsVersion();
786786
if (currentSettingsVersion == newSettingsVersion) {
787-
assert updateIndexSettings == false;
787+
assert updateIndexSettings == false : "No index updates are expected as index settings version has not changed";
788788
} else {
789-
assert updateIndexSettings;
789+
assert updateIndexSettings : "Index updates are expected as index settings version has changed";
790790
assert currentSettingsVersion < newSettingsVersion
791791
: "expected current settings version ["
792792
+ currentSettingsVersion

0 commit comments

Comments
 (0)