Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog/126077.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 126077
summary: Preventing `ConcurrentModificationException` when updating settings for more
than one index
area: Indices APIs
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public void testThatNonDynamicSettingChangesTakeEffect() throws Exception {
* This test makes sure that when non-dynamic settings are updated that they actually take effect (as opposed to just being set
* in the cluster state).
*/
createIndex("test", Settings.EMPTY);
createIndex("test-1", Settings.EMPTY);
createIndex("test-2", Settings.EMPTY);
MetadataUpdateSettingsService metadataUpdateSettingsService = internalCluster().getCurrentMasterNodeInstance(
MetadataUpdateSettingsService.class
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ ClusterState execute(ClusterState currentState) {
// We have non-dynamic settings and open indices. We will unassign all of the shards in these indices so that the new
// changed settings are applied when the shards are re-assigned.
routingTableBuilder = RoutingTable.builder(allocationService.getShardRoutingRoleStrategy(), currentRoutingTable);
for (Index index : openIndices) {
for (Index index : new HashSet<>(openIndices)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This HashSet constructor itself iterates over its parameter. Are we concerned about modifications while the constructor is running?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is single-threaded code. The openIndices object never escapes this thread.

// We only want to take on the expense of reopening all shards for an index if the setting is really changing
Settings existingSettings = currentProject.index(index).getSettings();
boolean needToReopenIndex = false;
Expand Down
Loading