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

CCR: Do not follow if leader does not have soft-deletes #34767

Merged
merged 5 commits into from
Oct 24, 2018

Conversation

dnhatn
Copy link
Member

@dnhatn dnhatn commented Oct 23, 2018

We should not create a follower index and abort a follow request if the
leader does not have soft-deletes. Moreover, we also should not
auto-follow an index if it does not have soft-deletes.

We should not create a follower index and abort a follow request if the
leader does not have soft-deletes. Moreover, we also should not
auto-follow an index if it does not have soft-deletes.
@dnhatn dnhatn added >non-issue :Distributed Indexing/CCR Issues around the Cross Cluster State Replication features labels Oct 23, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -370,7 +370,9 @@ private void finalise(int slot, AutoFollowResult result) {
// has a leader index uuid custom metadata entry that matches with uuid of leaderIndexMetaData variable
// If so then handle it differently: not follow it, but just add an entry to
// AutoFollowMetadata#followedLeaderIndexUUIDs
leaderIndicesToFollow.add(leaderIndexMetaData.getIndex());
if (TransportPutFollowAction.canFollow(clusterAlias, leaderIndexMetaData) == null) {
Copy link
Member

Choose a reason for hiding this comment

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

Initially I wanted to do this check in checkAutoFollowPattern(...) method, so that we could fail or log when an index can't be followed, but then I realized that we would do this for every auto follow run and that would be way to noisy. So I think this is the right place.

Copy link
Member

@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 comment.

* Pre-flight check if the given index can be a leader index.
* This method returns {@code null} if no issue found; otherwise it returns the first issue that it found.
*/
static Exception canFollow(String leaderCluster, IndexMetaData leaderIndexMetaData) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this needs to be a method shared between AutoFollowCoordinator and TransportPutFollowAction; I think that we can inline the check directly into the call sites. Then we can avoid having a debate about the method not throwing versus returning null versus returning an optional. 😇

Copy link
Member

Choose a reason for hiding this comment

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

If we think there is value in having this method (for example, maybe for future purposes), then let us discuss that.

Copy link
Member Author

Choose a reason for hiding this comment

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

The reason I introduced this method is for future purposes when we need to add one more check for the leader index. I am fine to inline it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I pushed b279bd7.

@dnhatn dnhatn requested a review from jasontedor October 23, 2018 22:56
Copy link
Member

@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 one more comment, otherwise LGTM.

@@ -125,6 +125,10 @@ private void createFollowerIndex(
listener.onFailure(new IllegalArgumentException("leader index [" + request.getLeaderIndex() + "] does not exist"));
return;
}
if (leaderIndexMetaData.getSettings().getAsBoolean(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), false) == false) {
listener.onFailure(
new IllegalArgumentException("leader index [" + request.getLeaderIndex() + "] does not enable soft-deletes"));
Copy link
Member

Choose a reason for hiding this comment

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

I think “does not have soft deletes enabled” was great!

@dnhatn
Copy link
Member Author

dnhatn commented Oct 24, 2018

Thanks @martijnvg and @jasontedor.

@dnhatn dnhatn merged commit d73768f into elastic:master Oct 24, 2018
@dnhatn dnhatn deleted the soft-deletes-leader branch October 24, 2018 15:19
dnhatn added a commit that referenced this pull request Oct 25, 2018
We should not create a follower index and abort a follow request if the
leader does not have soft-deletes. Moreover, we also should not
auto-follow an index if it does not have soft-deletes.
kcm pushed a commit that referenced this pull request Oct 30, 2018
We should not create a follower index and abort a follow request if the
leader does not have soft-deletes. Moreover, we also should not
auto-follow an index if it does not have soft-deletes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Indexing/CCR Issues around the Cross Cluster State Replication features >non-issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants