Skip to content
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

Replicate index settings to followers #35089

Merged
merged 21 commits into from Nov 8, 2018

Conversation

jasontedor
Copy link
Member

This commit uses the index settings version so that a follower can replicate index settings changes as needed from the leader.

This commit uses the index settings version so that a follower can
replicate index settings changes as needed from the leader.
@jasontedor jasontedor added >non-issue WIP :Distributed/CCR Issues around the Cross Cluster State Replication features labels Oct 30, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

@jasontedor
Copy link
Member Author

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.

@martijnvg
Copy link
Member

@jasontedor I think I have made this change production ready.

The most significant change is that the PersistentTaskPlugin interface has changed. This was needed to pass down IndexScopedSettings to ShardFollowTasksExecutor in order to determine whether index settings are dynamic.

@martijnvg martijnvg removed the WIP label Nov 1, 2018
@martijnvg
Copy link
Member

@elasticmachine run gradle build test

@martijnvg
Copy link
Member

run package tests please

Copy link
Member Author

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

I left a few comments. 😉

ThreadPool threadPool, Client client) {
ThreadPool threadPool,
Client client,
IndexScopedSettings indexScopedSettings) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Pushing SettingsModule would feel better to me. IndexScopedSettings feels too specific exactly to CCR needs.

}
}

if (onlyDynamicSettings) {
Copy link
Member Author

Choose a reason for hiding this comment

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

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) {
Copy link
Member Author

Choose a reason for hiding this comment

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

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) {
Copy link
Member Author

Choose a reason for hiding this comment

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

updateSettingsAndOpenIndex

@martijnvg
Copy link
Member

@jasontedor I've addressed the comments.

Copy link
Member Author

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

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). 🙏

@martijnvg
Copy link
Member

Thanks @jasontedor for reviewing!

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)

I think the testUpdateWhiteListedLeaderIndexSettings() test is already testing this? It sets the index.number_of_replicas on leader index and verifies that that setting does not percolate to the follower index, but it does expect that the settings version is incremented on the follower index.

I'll rename this test the better reflect what it is testing.

@jasontedor
Copy link
Member Author

Thanks for clarifying that test.

Copy link
Member Author

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

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

I can't approve this. LGTM.

@jasontedor jasontedor merged commit 4f4fc3b into elastic:master Nov 8, 2018
jasontedor added a commit that referenced this pull request Nov 8, 2018
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>
jasontedor added a commit that referenced this pull request Nov 8, 2018
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>
@jasontedor jasontedor deleted the ccr-index-settings-version branch November 8, 2018 02:47
@jasontedor jasontedor removed the blocker label Nov 8, 2018
jasontedor added a commit to martijnvg/elasticsearch that referenced this pull request Nov 8, 2018
* 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)
  ...
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Nov 8, 2018
* 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)
  ...
pgomulka pushed a commit to pgomulka/elasticsearch that referenced this pull request Nov 13, 2018
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed/CCR Issues around the Cross Cluster State Replication features >non-issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants