Skip to content

Commit 33675c4

Browse files
committed
assert live doc has highest seqno
1 parent 26993a3 commit 33675c4

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

server/src/main/java/org/elasticsearch/common/lucene/uid/PerThreadIDVersionAndSeqNoLookup.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ DocIdAndSeqNo lookupSeqNo(BytesRef id, LeafReaderContext context) throws IOExcep
160160
// The live document must always be the latest copy, thus we can early terminate here.
161161
// If a nested docs is live, we return the first doc which doesn't have term (only the last doc has term).
162162
// This should not be an issue since we no longer use primary term as tier breaker when comparing operations.
163+
assert result == null || result.seqNo <= seqNo :
164+
"the live doc does not have the highest seq_no; live_seq_no=" + seqNo + " < deleted_seq_no=" + result.seqNo;
163165
return new DocIdAndSeqNo(docID, seqNo, context, isLive);
164166
}
165167
if (result == null || result.seqNo < seqNo) {

server/src/main/java/org/elasticsearch/common/lucene/uid/VersionsAndSeqNoResolver.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ public static DocIdAndSeqNo loadDocIdAndSeqNo(IndexReader reader, Term term) thr
165165
}
166166
if (result.isLive) {
167167
// The live document must always be the latest copy, thus we can early terminate here.
168+
assert latest == null || latest.seqNo <= result.seqNo :
169+
"the live doc does not have the highest seq_no; live_seq_no=" + result.seqNo + " < deleted_seq_no=" + latest.seqNo;
168170
return result;
169171
}
170172
if (latest == null || latest.seqNo < result.seqNo) {

0 commit comments

Comments
 (0)