-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Noop peer recoveries on closed index #41400
Conversation
Pinging @elastic/es-distributed |
readonly engine does not support synced-flush
server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexStateService.java
Outdated
Show resolved
Hide resolved
@ywelsch I push changes. Can you take another look? Thank you! |
The more I came to think of this, I wonder if it is easier, as a first step, to avoid the issue of closed replicated indices doing file-based recovery by just changing |
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.
Thanks @dnhatn , I left a few comments to consider.
server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexStateService.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java
Outdated
Show resolved
Hide resolved
...org/elasticsearch/action/admin/indices/close/TransportVerifyShardBeforeCloseActionTests.java
Outdated
Show resolved
Hide resolved
@ywelsch Great idea! Sadly, this change does not play well with closed follower indices.
|
@henningandersen Discussed with Yannick on another channel, we agreed to go with Yannick's proposal; however, we need to strengthen the operation-based condition in ReadOnlyEngine (addressed in 35c527b). @ywelsch @henningandersen Can you please take another look? Thank you! |
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.
LGTM.
Thanks @dnhatn
@@ -338,6 +340,37 @@ public void testCloseIndexWaitForActiveShards() throws Exception { | |||
assertIndexIsClosed(indexName); | |||
} | |||
|
|||
public void testNoopPeerRecoveriesWhenIndexClosed() throws Exception { |
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 be nice to also test the scenario you described here:
where we expect file based recovery and verify same docs on all shards.
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.
@henningandersen Good suggestion. However we can't test that scenario for now since closing a follower index with gaps in sequence number will make all its shard unassigned; hence no peer recovery will be performed.
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.
@dnhatn Can you implement the test scenario that you've described for regular indices (instead of follower index)? It will then show that a closed replica index that is missing some docs IS doing a file-based recovery.
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 added a test in b50d3f2.
@elasticmachine test this please |
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.
LGTM
} | ||
} | ||
|
||
public void testRecoverExistingReplica() throws Exception { |
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.
perhaps add a comment that says that this tests recovery of a replica of a closed index that has some docs missing that were on the primary, leading to a file-based recovery
When an index is closed, we expect primary and replicas to be identical. This commit improves the gateway replica shard allocator to consider shards with identical sequence numbers sync'ed for closed indices. This ensures that we will pick a fast recovery regardless of whether synced flush was performed prior to closing an index. Relates elastic#41400 and elastic#33888
Added integration test validating that fast recovery is made for closed indices when multiple shard copies can be chosen from. Fixed InternalTestCluster to allow doing operations inside onStopped() when using restartXXXNode(). Relates elastic#41400 and elastic#33888
@ywelsch @henningandersen Thanks for reviewing. |
If users close an index to change some non-dynamic index settings, then the current implementation forces replicas of that closed index to copy over segment files from the primary. With this change, we make peer recoveries of closed index skip both phases. Relates #33888 Co-authored-by: Yannick Welsch <yannick@welsch.lu>
This is a first step away from sync-ids. We now check if replica and primary are identical using sequence numbers when determining where to allocate a replica shard. If an index is no longer indexed into, issuing a regular flush will now be enough to ensure a no-op recovery is done. This has the nice side-effect of ensuring that closed indices and frozen indices choose existing shard copies with identical data over file-overlap comparison, increasing the chance that we end up doing a no-op recovery (only no-op and file-based recovery is supported by closed indices). Relates elastic#41400 and elastic#33888 Supersedes elastic#41784
If users close an index to change some non-dynamic index settings, then the current implementation forces replicas of that closed index to copy over segment files from the primary. With this change, we make peer recoveries of closed index skip both phases. Relates elastic#33888 Co-authored-by: Yannick Welsch <yannick@welsch.lu>
If users close an index to change some non-dynamic index settings, then the current implementation forces replicas of that closed index to copy over segment files from the primary. With this change, we make peer recoveries of closed index skip both phases.
Relates #33888
Co-authored-by: Yannick Welsch yannick@welsch.lu