Skip to content

CCR: Following primary should process NoOps once#34408

Merged
dnhatn merged 5 commits intoelastic:masterfrom
dnhatn:noop-once
Oct 20, 2018
Merged

CCR: Following primary should process NoOps once#34408
dnhatn merged 5 commits intoelastic:masterfrom
dnhatn:noop-once

Conversation

@dnhatn
Copy link
Copy Markdown
Member

@dnhatn dnhatn commented Oct 11, 2018

This is a follow-up for #34288 (comment).

Relates #34288

@dnhatn dnhatn added >non-issue :Distributed/CCR Issues around the Cross Cluster State Replication features labels Oct 11, 2018
@dnhatn dnhatn requested a review from bleskes October 11, 2018 21:48
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-distributed

Copy link
Copy Markdown
Contributor

@bleskes bleskes left a comment

Choose a reason for hiding this comment

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

LGTM.

protected final boolean hasBeenProcessedBefore(Operation op) {
assert op.seqNo() != SequenceNumbers.UNASSIGNED_SEQ_NO : "operation is not assigned seq_no";
assert versionMap.assertKeyedLockHeldByCurrentThread(op.uid().bytes());
assert noOpKeyedLock.isHeldByCurrentThread(op.seqNo()) || versionMap.assertKeyedLockHeldByCurrentThread(op.uid().bytes());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we condition this on the op type?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

++

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I pushed 1df9b22

protected Optional<Exception> preFlightCheckForNoOp(NoOp noOp) {
if (noOp.origin() == Operation.Origin.PRIMARY && hasBeenProcessedBefore(noOp)) {
// See the comment in #indexingStrategyForOperation for the explanation why we can safely skip this operation.
return Optional.of(new AlreadyProcessedFollowingEngineException(shardId, noOp.seqNo()));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note that this will require changing the other PR to accept no opes with seq > gcp having no term and replicating them with current term.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, will do.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I pushed 8f19392

protected Optional<Exception> preFlightCheckForNoOp(NoOp noOp) throws IOException {
if (noOp.origin() == Operation.Origin.PRIMARY && hasBeenProcessedBefore(noOp)) {
// See the comment in #indexingStrategyForOperation for the explanation why we can safely skip this operation.
final OptionalLong existingTerm = lookupPrimaryTerm(noOp.seqNo());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

random thought - I wonder if we should load the operation under assertion code and check it's the same (this goes for all duplicate ops).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Do you mean the existing operation should equal the processing operation except for the primary term?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yes

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

++. I'll make it in a follow-up after this PR.

Clear the injected exception after the indexing
@dnhatn
Copy link
Copy Markdown
Member Author

dnhatn commented Oct 20, 2018

Thanks @bleskes.

@dnhatn dnhatn merged commit d90b673 into elastic:master Oct 20, 2018
@dnhatn dnhatn deleted the noop-once branch October 20, 2018 01:10
dnhatn added a commit that referenced this pull request Oct 21, 2018
kcm pushed a commit that referenced this pull request Oct 30, 2018
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.

3 participants