-
Notifications
You must be signed in to change notification settings - Fork 25.4k
Preventing ConcurrentModificationException when updating settings for more than one index #126077
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preventing ConcurrentModificationException when updating settings for more than one index #126077
Conversation
… more than one index
Pinging @elastic/es-data-management (Team:Data Management) |
Hi @masseyke, I've created a changelog YAML for you. |
…ding a NodeFeature
… of github.com:masseyke/elasticsearch into fix/ConcurrentModificationException-in-settings-update
@@ -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)) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I already know the answer to my question above.
💔 Backport failed
You can use sqren/backport to manually backport by running |
… more than one index (elastic#126077) (cherry picked from commit bb76210) # Conflicts: # server/src/main/java/org/elasticsearch/cluster/metadata/MetadataUpdateSettingsService.java
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
… more than one index (elastic#126077) (cherry picked from commit bb76210) # Conflicts: # server/src/main/java/org/elasticsearch/cluster/metadata/MetadataUpdateSettingsService.java
… more than one index (elastic#126077) (cherry picked from commit bb76210) # Conflicts: # server/src/main/java/org/elasticsearch/cluster/metadata/MetadataUpdateSettingsService.java
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.