Skip to content

Add retention leases replication tests #38857

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

Merged
merged 5 commits into from
Feb 20, 2019

Conversation

dnhatn
Copy link
Member

@dnhatn dnhatn commented Feb 13, 2019

This commit introduces the retention leases to ESIndexLevelReplicationTestCase, then adds some tests verifying that the retention leases replication works correctly in spite of the presence of the primary failover or out of order delivery of retention leases sync requests.

Relates #37165

@dnhatn dnhatn added >test Issues or PRs that are addressing/adding tests :Distributed Indexing/Distributed A catch all label for anything in the Distributed Indexing Area. Please avoid if you can. v6.7.0 v8.0.0 v7.2.0 v7.0.0-beta1 labels Feb 13, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

}
}
}
group.promoteReplicaToPrimary(newPrimary).get();
Copy link
Member Author

Choose a reason for hiding this comment

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

Discuss: should we align the retention-leases when a new primary is promoted?

Copy link
Contributor

Choose a reason for hiding this comment

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

Under what circumstances can the new primary not hold an up-to-date set of leases already? It might perhaps be missing some renewals but I think that's ok.

Copy link
Member Author

Choose a reason for hiding this comment

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

We are adding two new leases to the old primary: L1 and L2. L1 was synced to replica r1; L2 was synced to r2, but the old primary crashed before two leases are properly synced to all two replicas. If any replica is promoted, then the retention leases between copies are not aligned.

Copy link
Contributor

@DaveCTurner DaveCTurner Feb 19, 2019

Choose a reason for hiding this comment

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

We sync by copying all the leases from the primary to its replicas, so I don't follow how r2 could receive L2 without also receiving L1 (assuming they were added in this order).

However, I think I do see a potential problem:

  • primary A shares a lease with one replica B, but not to another replica C
  • A crashes
  • C discards some history that the lease would have retained
  • B is promoted to primary and shares its lease with C
  • C cannot accept this lease since it has already discarded this history

I think we can prevent this, with peer-recovery retention leases, by insisting that leases do not "go backwards", i.e. they only retain history that is already being retained by another lease. This would mean that C could not discard the history in the situation above because it must already hold a different lease that retains that history.

@jasontedor jasontedor mentioned this pull request Feb 13, 2019
24 tasks
@dnhatn
Copy link
Member Author

dnhatn commented Feb 13, 2019

run elasticsearch-ci/1

@ywelsch ywelsch removed their request for review February 15, 2019 10:29
Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

Looks good - I needed to make similar adjustments to support peer-recovery retention leases. I left some minor comments. Also there are now merge conflicts.

}
}
}
group.promoteReplicaToPrimary(newPrimary).get();
Copy link
Contributor

Choose a reason for hiding this comment

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

Under what circumstances can the new primary not hold an up-to-date set of leases already? It might perhaps be missing some renewals but I think that's ok.


@Override
public void backgroundSync(ShardId shardId, RetentionLeases retentionLeases) {
sync(shardId, retentionLeases, ActionListener.wrap(r -> {}, e -> fail("fail to sync retention leases [" + e + "]")));
Copy link
Contributor

Choose a reason for hiding this comment

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

I slightly prefer throw AssertionError("failed to sync retention leases", e); rather than putting the inner stack trace in the message like this.

Copy link
Member Author

Choose a reason for hiding this comment

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

done


public static WritePrimaryResult<Request, Response> performOnPrimary(final Request request,
final IndexShard primary,
final Logger logger) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we assert that we hold an operation permit here?

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 sync action is too thin now, so I inline it directly to the test.

return performOnReplica(request, replica, logger);
}

public static WriteReplicaResult<Request> performOnReplica(final Request request, final IndexShard replica, final Logger logger) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we assert that we hold an operation permit here?

@dnhatn
Copy link
Member Author

dnhatn commented Feb 19, 2019

Thanks for looking @DaveCTurner. I have addressed your comments. Can you have another look?

@dnhatn dnhatn requested a review from DaveCTurner February 19, 2019 18:20
Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

LGTM

@dnhatn
Copy link
Member Author

dnhatn commented Feb 20, 2019

Thanks @DaveCTurner.

@dnhatn dnhatn merged commit 8d9b391 into elastic:master Feb 20, 2019
@dnhatn dnhatn deleted the leases-test-replication branch February 20, 2019 13:08
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Feb 20, 2019
* master:
  Mute failing CCR retention lease unfollow test
  Add support for ccr follow info api to HLRC. (elastic#39115)
  Do not create the missing index when invoking getRole (elastic#39039)
  Relax history check in ShardFollowTaskReplicationTests (elastic#39162)
  Add retention leases replication tests (elastic#38857)
  Edits to text in Phrase Suggester doc (elastic#38966)
  Edits to text in API Conventions docs (elastic#39001)
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Feb 20, 2019
* master:
  Mute failing CCR retention lease unfollow test
  Add support for ccr follow info api to HLRC. (elastic#39115)
  Do not create the missing index when invoking getRole (elastic#39039)
  Relax history check in ShardFollowTaskReplicationTests (elastic#39162)
  Add retention leases replication tests (elastic#38857)
  Edits to text in Phrase Suggester doc (elastic#38966)
  Edits to text in API Conventions docs (elastic#39001)
dnhatn added a commit that referenced this pull request Feb 21, 2019
This commit introduces the retention leases to ESIndexLevelReplicationTestCase,
then adds some tests verifying that the retention leases replication works
correctly in spite of the presence of the primary failover or out of order
delivery of retention leases sync requests.

Relates #37165
dnhatn added a commit that referenced this pull request Feb 21, 2019
This commit introduces the retention leases to ESIndexLevelReplicationTestCase,
then adds some tests verifying that the retention leases replication works
correctly in spite of the presence of the primary failover or out of order
delivery of retention leases sync requests.

Relates #37165
dnhatn added a commit that referenced this pull request Feb 21, 2019
This commit introduces the retention leases to ESIndexLevelReplicationTestCase,
then adds some tests verifying that the retention leases replication works
correctly in spite of the presence of the primary failover or out of order
delivery of retention leases sync requests.
weizijun pushed a commit to weizijun/elasticsearch that referenced this pull request Feb 22, 2019
This commit introduces the retention leases to ESIndexLevelReplicationTestCase,
then adds some tests verifying that the retention leases replication works
correctly in spite of the presence of the primary failover or out of order
delivery of retention leases sync requests.

Relates elastic#37165
weizijun pushed a commit to weizijun/elasticsearch that referenced this pull request Feb 22, 2019
This commit introduces the retention leases to ESIndexLevelReplicationTestCase,
then adds some tests verifying that the retention leases replication works
correctly in spite of the presence of the primary failover or out of order
delivery of retention leases sync requests.

Relates elastic#37165
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Indexing/Distributed A catch all label for anything in the Distributed Indexing Area. Please avoid if you can. >test Issues or PRs that are addressing/adding tests v6.7.0 v7.0.0-rc2 v7.2.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants