-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Introduce index settings version #34429
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
Changes from all commits
f28aca4
9acdbad
2100f00
2c4d7ec
90829ac
bbefe40
94b6934
a8047b1
e7c03e7
d535225
dd7496d
6f2495f
e762281
d319cc3
60c15be
59d0f3d
9aa6810
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,7 @@ | |
| import java.util.Set; | ||
|
|
||
| import static org.elasticsearch.action.support.ContextPreservingActionListener.wrapPreservingContext; | ||
| import static org.elasticsearch.index.IndexSettings.same; | ||
|
|
||
| /** | ||
| * Service responsible for submitting update index settings requests | ||
|
|
@@ -187,6 +188,14 @@ public ClusterState execute(ClusterState currentState) { | |
| } | ||
| } | ||
|
|
||
| // increment settings versions | ||
| for (final String index : actualIndices) { | ||
| if (same(currentState.metaData().index(index).getSettings(), metaDataBuilder.get(index).getSettings()) == false) { | ||
| final IndexMetaData.Builder builder = IndexMetaData.builder(metaDataBuilder.get(index)); | ||
| builder.settingsVersion(1 + builder.settingsVersion()); | ||
| metaDataBuilder.put(builder); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we instead increment the version at lines 169 and 185? like: At these places we do know that the index versions have been updated. And then we don't have to check whether settings have been changed in another for loop.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would not be correct since a settings update does not necessarily mutate any settings. The test
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for adding that test! |
||
| } | ||
| } | ||
|
|
||
| ClusterState updatedState = ClusterState.builder(currentState).metaData(metaDataBuilder).routingTable(routingTableBuilder.build()).blocks(blocks).build(); | ||
|
|
||
|
|
@@ -220,9 +229,9 @@ public ClusterState execute(ClusterState currentState) { | |
| */ | ||
| private static void maybeUpdateClusterBlock(String[] actualIndices, ClusterBlocks.Builder blocks, ClusterBlock block, Setting<Boolean> setting, Settings openSettings) { | ||
| if (setting.exists(openSettings)) { | ||
| final boolean updateReadBlock = setting.get(openSettings); | ||
| final boolean updateBlock = setting.get(openSettings); | ||
| for (String index : actualIndices) { | ||
| if (updateReadBlock) { | ||
| if (updateBlock) { | ||
| blocks.addIndexBlock(index, block); | ||
| } else { | ||
| blocks.removeIndexBlock(index, block); | ||
|
|
||
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.
would it make sense to check that we always increase?
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.
That would not be correct since this method is called when building index metadata from parsing or de-serializing.