Preventing ConcurrentModificationException when updating settings for more than one index#126077
Merged
masseyke merged 6 commits intoelastic:mainfrom Apr 1, 2025
Conversation
… more than one index
Collaborator
|
Pinging @elastic/es-data-management (Team:Data Management) |
Collaborator
|
Hi @masseyke, I've created a changelog YAML for you. |
…ding a NodeFeature
… of github.com:masseyke/elasticsearch into fix/ConcurrentModificationException-in-settings-update
prdoyle
reviewed
Apr 1, 2025
| // 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)) { |
Contributor
There was a problem hiding this comment.
This HashSet constructor itself iterates over its parameter. Are we concerned about modifications while the constructor is running?
Member
Author
There was a problem hiding this comment.
No, this is single-threaded code. The openIndices object never escapes this thread.
prdoyle
approved these changes
Apr 1, 2025
Contributor
prdoyle
left a comment
There was a problem hiding this comment.
I think I already know the answer to my question above.
Collaborator
💔 Backport failed
You can use sqren/backport to manually backport by running |
masseyke
added a commit
to masseyke/elasticsearch
that referenced
this pull request
Apr 2, 2025
… more than one index (elastic#126077) (cherry picked from commit bb76210) # Conflicts: # server/src/main/java/org/elasticsearch/cluster/metadata/MetadataUpdateSettingsService.java
Member
Author
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
masseyke
added a commit
to masseyke/elasticsearch
that referenced
this pull request
Apr 2, 2025
… more than one index (elastic#126077) (cherry picked from commit bb76210) # Conflicts: # server/src/main/java/org/elasticsearch/cluster/metadata/MetadataUpdateSettingsService.java
masseyke
added a commit
to masseyke/elasticsearch
that referenced
this pull request
Apr 2, 2025
… more than one index (elastic#126077) (cherry picked from commit bb76210) # Conflicts: # server/src/main/java/org/elasticsearch/cluster/metadata/MetadataUpdateSettingsService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In #101723 we added the ability to update settings that require an index to be closed, by adding a URL parameter called
reopen. However, if you attempt to update one of these settings on more than one index at a time, it fails with a ConcurrentModificationException because we remove items from a Set that we are iterating through. This fixes it by creating a defensive copy of the Set.