Skip to content

Commit 57adbda

Browse files
authored
Preventing ConcurrentModificationException when updating settings for more than one index (elastic#126077) (elastic#126129)
1 parent 448d654 commit 57adbda

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

docs/changelog/126077.yaml

+6
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

+2-1
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

+1-1
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)