Skip to content

Commit 34d7cc1

Browse files
SETTINGS: Correctly Identify Noop Updates (#36560)
* We should compare the target value with the to be applied value before interpreting the update as a change * This speeds up the test failing in #36496 considerably by preventing state updates on noop setting updates
1 parent c650be7 commit 34d7cc1

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

server/src/main/java/org/elasticsearch/common/settings/AbstractScopedSettings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ private boolean updateSettings(Settings toApply, Settings.Builder target, Settin
726726
validate(key, toApply, false); // we might not have a full picture here do to a dependency validation
727727
settingsBuilder.copy(key, toApply);
728728
updates.copy(key, toApply);
729-
changed = true;
729+
changed |= toApply.get(key).equals(target.get(key)) == false;
730730
} else {
731731
if (isFinalSetting(key)) {
732732
throw new IllegalArgumentException("final " + type + " setting [" + key + "], not updateable");

server/src/test/java/org/elasticsearch/common/settings/ScopedSettingsTests.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,17 @@ public void testResetSettingWithIPValidator() {
136136
assertEquals(1, currentSettings.size());
137137
}
138138

139+
public void testNoopSettingsUpdate() {
140+
String value = "192.168.0.1,127.0.0.1";
141+
String setting = "index.routing.allocation.require._ip";
142+
Settings currentSettings = Settings.builder().put(setting, value)
143+
.build();
144+
Settings updates = Settings.builder().put(setting, value).build();
145+
IndexScopedSettings settings = new IndexScopedSettings(currentSettings,
146+
new HashSet<>(Collections.singletonList(IndexMetaData.INDEX_ROUTING_REQUIRE_GROUP_SETTING)));
147+
assertFalse(settings.updateSettings(updates, Settings.builder().put(currentSettings), Settings.builder(), ""));
148+
}
149+
139150
public void testAddConsumer() {
140151
Setting<Integer> testSetting = Setting.intSetting("foo.bar", 1, Property.Dynamic, Property.NodeScope);
141152
Setting<Integer> testSetting2 = Setting.intSetting("foo.bar.baz", 1, Property.Dynamic, Property.NodeScope);

0 commit comments

Comments
 (0)