Skip to content

Commit 799cf01

Browse files
committed
Preventing ConcurrentModificationException when updating settings for more than one index (#126077)
(cherry picked from commit bb76210) # Conflicts: # server/src/main/java/org/elasticsearch/cluster/metadata/MetadataUpdateSettingsService.java
1 parent 00ffed0 commit 799cf01

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

docs/changelog/126077.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 126077
2+
summary: Preventing `ConcurrentModificationException` when updating settings for more
3+
than one index
4+
area: Indices APIs
5+
type: bug
6+
issues: []

server/src/internalClusterTest/java/org/elasticsearch/cluster/metadata/MetadataUpdateSettingsServiceIT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public void testThatNonDynamicSettingChangesTakeEffect() throws Exception {
3939
* This test makes sure that when non-dynamic settings are updated that they actually take effect (as opposed to just being set
4040
* in the cluster state).
4141
*/
42-
createIndex("test", Settings.EMPTY);
42+
createIndex("test-1", Settings.EMPTY);
43+
createIndex("test-2", Settings.EMPTY);
4344
MetadataUpdateSettingsService metadataUpdateSettingsService = internalCluster().getCurrentMasterNodeInstance(
4445
MetadataUpdateSettingsService.class
4546
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ ClusterState execute(ClusterState currentState) {
219219
allocationService.getShardRoutingRoleStrategy(),
220220
currentState.routingTable()
221221
);
222-
for (Index index : openIndices) {
222+
for (Index index : new HashSet<>(openIndices)) {
223223
// We only want to take on the expense of reopening all shards for an index if the setting is really changing
224224
Settings existingSettings = currentState.getMetadata().index(index).getSettings();
225225
boolean needToReopenIndex = false;

0 commit comments

Comments
 (0)