Replicate index settings to followers#35089
Conversation
This commit uses the index settings version so that a follower can replicate index settings changes as needed from the leader.
|
Pinging @elastic/es-distributed |
|
This code is really a POC, there is some work to be done to make this production-ready, and tests are needed. This effort will be picked up by @martijnvg. |
|
@jasontedor I think I have made this change production ready. The most significant change is that the |
|
@elasticmachine run gradle build test |
|
run package tests please |
jasontedor
left a comment
There was a problem hiding this comment.
I left a few comments. 😉
| ThreadPool threadPool, Client client) { | ||
| ThreadPool threadPool, | ||
| Client client, | ||
| IndexScopedSettings indexScopedSettings) { |
There was a problem hiding this comment.
Pushing SettingsModule would feel better to me. IndexScopedSettings feels too specific exactly to CCR needs.
| } | ||
| } | ||
|
|
||
| if (onlyDynamicSettings) { |
There was a problem hiding this comment.
Maybe:
diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java
index 6cef9689409..2049bf39989 100644
--- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java
+++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java
@@ -170,16 +170,7 @@ public class ShardFollowTasksExecutor extends PersistentTasksExecutor<ShardFollo
s -> existingSettings.get(s) == null || existingSettings.get(s).equals(settings.get(s)) == false
);
- // Figure out whether the updated settings are all dynamic settings:
- boolean onlyDynamicSettings = true;
- for (String key : updatedSettings.keySet()) {
- if (indexScopedSettings.isDynamicSetting(key) == false) {
- onlyDynamicSettings = false;
- break;
- }
- }
-
- if (onlyDynamicSettings) {
+ if (updatedSettings.keySet().stream().allMatch(indexScopedSettings::isDynamicSetting)) {
// If only dynamic settings have been updated then just update these settings in follower index:
final UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest(followIndex.getName());
updateSettingsRequest.settings(updatedSettings);| leaderClient.admin().cluster().state(clusterStateRequest, ActionListener.wrap(onResponse, errorHandler)); | ||
| } | ||
|
|
||
| private void closeIndex(String followIndex, Settings updatedSettings, Runnable handler, Consumer<Exception> onFailure) { |
There was a problem hiding this comment.
This should probably be named closeIndexUpdateSettingsAndOpenIndex.
| followerClient.admin().indices().close(closeRequest, ActionListener.wrap(onResponse, onFailure)); | ||
| } | ||
|
|
||
| private void updateSettings(String followIndex, Settings updatedSettings, Runnable handler, Consumer<Exception> onFailure) { |
There was a problem hiding this comment.
updateSettingsAndOpenIndex
…SettingsModule` instead of `IndexScopedSettings`
|
@jasontedor I've addressed the comments. |
jasontedor
left a comment
There was a problem hiding this comment.
I can't approve this PR. Would you also add a test for updating a setting that shouldn't percolate to the follower (so that the setting version indeed changes, but there's no settings change on the follower). Then I am good with this PR being merged.
Thank you for all the work here, and taking my POC to the finish line. This is great work by you (really, I gave you something rough, you polished it really nicely, and made it production-ready). 🙏
|
Thanks @jasontedor for reviewing!
I think the I'll rename this test the better reflect what it is testing. |
|
Thanks for clarifying that test. |
jasontedor
left a comment
There was a problem hiding this comment.
I can't approve this. LGTM.
This commit uses the index settings version so that a follower can replicate index settings changes as needed from the leader. Co-authored-by: Martijn van Groningen <martijn.v.groningen@gmail.com>
This commit uses the index settings version so that a follower can replicate index settings changes as needed from the leader. Co-authored-by: Martijn van Groningen <martijn.v.groningen@gmail.com>
* master: (24 commits) Replicate index settings to followers (elastic#35089) Rename RealmConfig.globalSettings() to settings() (elastic#35330) [TEST] Cleanup FileUserPasswdStoreTests (elastic#35329) Scripting: Add back lookup vars in score script (elastic#34833) watcher: Fix integration tests to ensure correct start/stop of Watcher (elastic#35271) Remove ALL shard check in CheckShrinkReadyStep (elastic#35346) Use soft-deleted docs to resolve strategy for engine operation (elastic#35230) [ILM] Check shard and relocation status in AllocationRoutedStep (elastic#35316) Ignore date ranges containing 'now' when pre-processing a percolator query (elastic#35160) Add a frozen engine implementation (elastic#34357) Put a fake allocation id on allocate stale primary command (elastic#34140) [CCR] Enforce auto follow pattern name restrictions (elastic#35197) [ILM] rolling upgrade tests (elastic#35328) [ML] Add Missing data checking class (elastic#35310) Apply `ignore_throttled` also to concrete indices (elastic#35335) Make version field names more meaningful (elastic#35334) [CCR] Added HLRC support for pause follow API (elastic#35216) [Docs] Improve Convert Processor description (elastic#35280) [Painless] Removes extraneous compile method (elastic#35323) [CCR] Fail with a better error if leader index is red (elastic#35298) ...
* elastic/master: (25 commits) Fixes fast vector highlighter docs per issue 24318. (elastic#34190) [ML] Prevent notifications on deletion of a non existent job (elastic#35337) [CCR] Auto follow Coordinator fetch cluster state in system context (elastic#35120) Mute test for elastic#35361 Preserve `date_histogram` format when aggregating on unmapped fields (elastic#35254) Test: Mute failing SSL test Allow unmapped fields in composite aggregations (elastic#35331) [RCI] Add IndexShardOperationPermits.asyncBlockOperations(ActionListener<Releasable>) (elastic#34902) HLRC: reindex API with wait_for_completion false (elastic#35202) Add docs on JNA temp directory not being noexec (elastic#35355) [CCR] Adjust list of dynamic index settings that should be replicated (elastic#35195) Replicate index settings to followers (elastic#35089) Rename RealmConfig.globalSettings() to settings() (elastic#35330) [TEST] Cleanup FileUserPasswdStoreTests (elastic#35329) Scripting: Add back lookup vars in score script (elastic#34833) watcher: Fix integration tests to ensure correct start/stop of Watcher (elastic#35271) Remove ALL shard check in CheckShrinkReadyStep (elastic#35346) Use soft-deleted docs to resolve strategy for engine operation (elastic#35230) [ILM] Check shard and relocation status in AllocationRoutedStep (elastic#35316) Ignore date ranges containing 'now' when pre-processing a percolator query (elastic#35160) ...
This commit uses the index settings version so that a follower can replicate index settings changes as needed from the leader. Co-authored-by: Martijn van Groningen <martijn.v.groningen@gmail.com>
This commit uses the index settings version so that a follower can replicate index settings changes as needed from the leader.