-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
[ILM] Add unfollow action #36970
[ILM] Add unfollow action #36970
Conversation
This change adds the unfollow action for CCR follower indices. This is needed for the shrink action in case an index is a follower index. This will give the follower index the opportunity to fully catch up with the leader index, pause index following and unfollow the leader index. After this the shrink action can safely perform the ilm shrink. The unfollow action needs to be added to the hot phase and acts as barrier for going to the next phase (warm or delete phases), so that follower indices are being unfollowed properly before indices are expected to go in read-only mode. This allows the force merge action to execute its steps safely. The unfollow action has three steps: * `wait-for-indexing-complete` step: waits for the index in question to get the `index.lifecycle.indexing_complete` setting be set to `true` * `wait-for-follow-shard-tasks` step: waits for all the shard follow tasks for the index being handled to report that the leader shard global checkpoint is equal to the follower shard global checkpoint. * `unfollow-index` step: actually performs the unfollow. This consists out of multiple operations being executed on the index being handled: pause index following, close index, unfollow and open index. (a follower index can only be unfollowed when it is closed, because the underlying engine is changed) In the case of the last two steps, if the index in being handled is a regular index then the steps acts as a no-op. Relates to elastic#34648
Pinging @elastic/es-core-features |
changed WaitForIndexingComplete step to always ignore non follower indices.
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.
Made some comments - some are questions, some are just to help track what still needs to be done with the understanding that this is still a WIP.
@martijnvg Don't worry about this until you get back - I'll work on this a bit like we discussed. I don't think this needs major changes, just a few tweaks/another integration test/etc.
...e/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/WaitForFollowShardTasksStep.java
Show resolved
Hide resolved
.../core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/WaitForIndexingComplete.java
Outdated
Show resolved
Hide resolved
.../core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/WaitForIndexingComplete.java
Outdated
Show resolved
Hide resolved
.../src/test/java/org/elasticsearch/xpack/core/indexlifecycle/UnfollowFollowIndexStepTests.java
Outdated
Show resolved
Hide resolved
.../core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/UnfollowFollowIndexStep.java
Outdated
Show resolved
Hide resolved
Client client = Mockito.mock(Client.class); | ||
List<FollowStatsAction.StatsResponse> statsResponses = Arrays.asList( | ||
new FollowStatsAction.StatsResponse(createShardFollowTaskStatus(0, 9, 9)), | ||
new FollowStatsAction.StatsResponse(createShardFollowTaskStatus(1, 3, 3)) |
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.
These checkpoint values seems like a good candidate for randomization.
.../multi-cluster/src/test/java/org/elasticsearch/xpack/indexlifecycle/CCRIndexLifecycleIT.java
Show resolved
Hide resolved
.../core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/UnfollowFollowIndexStep.java
Outdated
Show resolved
Hide resolved
.../src/test/java/org/elasticsearch/xpack/core/indexlifecycle/TimeseriesLifecycleTypeTests.java
Show resolved
Hide resolved
This aligns WaitForIndexingCompleteStep with naming conventions
.../multi-cluster/src/test/java/org/elasticsearch/xpack/indexlifecycle/CCRIndexLifecycleIT.java
Outdated
Show resolved
Hide resolved
The shard follow tasks continuesly poll changes from leader index, in case no new writes arrive in the leader shards, then the leader shards wait up to the defined read_poll_timeout before returning an empty result. The result also includes information about whether the index settings need to be synced. Because in this test no data was indexed it took a full minute for ccr to realize that the followe index settings needed to be updated and caused the test to fail due to an assert busy statement to time out.
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 left some comments, thanks for doing this Martijn!
...ck/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/UnfollowAction.java
Show resolved
Hide resolved
...ck/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/UnfollowAction.java
Outdated
Show resolved
Hide resolved
...ck/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/UnfollowAction.java
Show resolved
Hide resolved
.../core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/UnfollowFollowIndexStep.java
Outdated
Show resolved
Hide resolved
.../core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/UnfollowFollowIndexStep.java
Outdated
Show resolved
Hide resolved
.../core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/UnfollowFollowIndexStep.java
Outdated
Show resolved
Hide resolved
.../core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/UnfollowFollowIndexStep.java
Outdated
Show resolved
Hide resolved
.../core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/UnfollowFollowIndexStep.java
Outdated
Show resolved
Hide resolved
...e/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/WaitForIndexingCompleteStep.java
Outdated
Show resolved
Hide resolved
I spent a bit of time trying to track down the test failures, I saw a couple variations of failure but the one that reliably reproduces is that the test times out waiting for the |
The reason the qa test failed, was because of a silly bug: |
because after the unfollow step it is no longer a follower index.
As requested by @bmcconaghy, we're going to add the status of the |
...e/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/WaitForIndexingCompleteStep.java
Outdated
Show resolved
Hide resolved
...e/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/WaitForIndexingCompleteStep.java
Outdated
Show resolved
Hide resolved
@elasticmachine run gradle build tests 2 |
1 similar comment
@elasticmachine run gradle build tests 2 |
@elasticmachine run gradle build tests 1 |
@elasticmachine run gradle build tests 2 |
This is necessary, at least in the Hot phase, so that the priority will be set before waiting for the index to unfollow, which is much more likely what the user expects.
@elasticmachine run gradle build tests 2 please |
1 similar comment
@elasticmachine run gradle build tests 2 please |
* elastic/master: (104 commits) Permission for restricted indices (elastic#37577) Remove Watcher Account "unsecure" settings (elastic#36736) Add cache cleaning task for ML snapshot (elastic#37505) Update jdk used by the docker builds (elastic#37621) Remove an unused constant in PutMappingRequest. Update get users to allow unknown fields (elastic#37593) Do not add index event listener if CCR disabled (elastic#37432) Add local session timeouts to leader node (elastic#37438) Add some deprecation optimizations (elastic#37597) refactor inner geogrid classes to own class files (elastic#37596) Remove obsolete deprecation checks (elastic#37510) ML: Add support for single bucket aggs in Datafeeds (elastic#37544) ML: creating ML State write alias and pointing writes there (elastic#37483) Deprecate types in the put mapping API. (elastic#37280) [ILM] Add unfollow action (elastic#36970) Packaging: Update marker used to allow ELASTIC_PASSWORD (elastic#37243) Fix setting openldap realm ssl config Document the need for JAVA11_HOME (elastic#37589) SQL: fix object extraction from sources (elastic#37502) Nit in settings.gradle for Eclipse ...
This change adds the unfollow action for CCR follower indices. This is needed for the shrink action in case an index is a follower index. This will give the follower index the opportunity to fully catch up with the leader index, pause index following and unfollow the leader index. After this the shrink action can safely perform the ilm shrink. The unfollow action needs to be added to the hot phase and acts as barrier for going to the next phase (warm or delete phases), so that follower indices are being unfollowed properly before indices are expected to go in read-only mode. This allows the force merge action to execute its steps safely. The unfollow action has three steps: * `wait-for-indexing-complete` step: waits for the index in question to get the `index.lifecycle.indexing_complete` setting be set to `true` * `wait-for-follow-shard-tasks` step: waits for all the shard follow tasks for the index being handled to report that the leader shard global checkpoint is equal to the follower shard global checkpoint. * `pause-follower-index` step: Pauses index following, necessary to unfollow * `close-follower-index` step: Closes the index, necessary to unfollow * `unfollow-follower-index` step: Actually unfollows the index using the CCR Unfollow API * `open-follower-index` step: Reopens the index now that it is a normal index * `wait-for-yellow` step: Waits for primary shards to be allocated after reopening the index to ensure the index is ready for the next step In the case of the last two steps, if the index in being handled is a regular index then the steps acts as a no-op. Relates to #34648 Co-authored-by: Martijn van Groningen <martijn.v.groningen@gmail.com> Co-authored-by: Gordon Brown <gordon.brown@elastic.co>
This change adds the unfollow action for CCR follower indices.
This is needed for the shrink action in case an index is a follower index.
This will give the follower index the opportunity to fully catch up with
the leader index, pause index following and unfollow the leader index.
After this the shrink action can safely perform the ilm shrink.
The unfollow action needs to be added to the hot phase and acts as
barrier for going to the next phase (warm or delete phases), so that
follower indices are being unfollowed properly before indices are expected
to go in read-only mode. This allows the force merge action to execute
its steps safely.
The unfollow action has three steps:
wait-for-indexing-complete
step: waits for the index in questionto get the
index.lifecycle.indexing_complete
setting be set totrue
wait-for-follow-shard-tasks
step: waits for all the shard follow tasksfor the index being handled to report that the leader shard global checkpoint
is equal to the follower shard global checkpoint.
unfollow-index
step: actually performs the unfollow. This consistsout of multiple operations being executed on the index being handled:
pause index following, close index, unfollow and open index. (a follower
index can only be unfollowed when it is closed, because the underlying
engine is changed)
In the case of the last two steps, if the index in being handled is
a regular index then the steps acts as a no-op.
Relates to #34648