Skip to content

Commit 1c14260

Browse files
committed
Skip adding operations without sequence number
A version conflict exception can happen during recovery. If this operation is from an old primary, a sequence number will have not been assigned to the operation. In this case, we should skip adding a no-op to the translog.
1 parent 91e1ff0 commit 1c14260

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

core/src/main/java/org/elasticsearch/index/engine/InternalEngine.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ private IndexResult innerIndex(Index index) throws IOException {
671671
if (checkVersionConflictResult.isPresent()) {
672672
indexResult = checkVersionConflictResult.get();
673673
// norelease: this is not correct as this does not force an fsync, and we need to handle failures including replication
674-
if (indexResult.hasFailure()) {
674+
if (indexResult.hasFailure() || seqNo == SequenceNumbersService.UNASSIGNED_SEQ_NO) {
675675
location = null;
676676
} else {
677677
final Translog.NoOp operation = new Translog.NoOp(seqNo, index.primaryTerm(), "version conflict during recovery");
@@ -809,7 +809,7 @@ private DeleteResult innerDelete(Delete delete) throws IOException {
809809
if (result.isPresent()) {
810810
deleteResult = result.get();
811811
// norelease: this is not correct as this does not force an fsync, and we need to handle failures including replication
812-
if (deleteResult.hasFailure()) {
812+
if (deleteResult.hasFailure() || seqNo == SequenceNumbersService.UNASSIGNED_SEQ_NO) {
813813
location = null;
814814
} else {
815815
final Translog.NoOp operation = new Translog.NoOp(seqNo, delete.primaryTerm(), "version conflict during recovery");

0 commit comments

Comments
 (0)