Skip to content

Commit

Permalink
lookup the existing term
Browse files Browse the repository at this point in the history
  • Loading branch information
dnhatn committed Oct 19, 2018
1 parent 40fb87e commit 8f19392
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,7 @@ private NoOpResult innerNoOp(final NoOp noOp) throws IOException {
* Executes a pre-flight check for a given NoOp.
* If this method returns a non-empty result, the engine won't process this NoOp and returns a failure.
*/
protected Optional<Exception> preFlightCheckForNoOp(final NoOp noOp) {
protected Optional<Exception> preFlightCheckForNoOp(final NoOp noOp) throws IOException {
return Optional.empty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,11 @@ protected InternalEngine.DeletionStrategy deletionStrategyForOperation(final Del
}

@Override
protected Optional<Exception> preFlightCheckForNoOp(NoOp noOp) {
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.
return Optional.of(new AlreadyProcessedFollowingEngineException(shardId, noOp.seqNo()));
final OptionalLong existingTerm = lookupPrimaryTerm(noOp.seqNo());
return Optional.of(new AlreadyProcessedFollowingEngineException(shardId, noOp.seqNo(), existingTerm));
} else {
return super.preFlightCheckForNoOp(noOp);
}
Expand Down

0 comments on commit 8f19392

Please sign in to comment.