Skip to content

Commit 3cd8392

Browse files
committed
TEST: Skip asserting Lucene history for an empty index
This maximization is not correct if the Lucene index is empty.
1 parent 2c56df6 commit 3cd8392

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

test/framework/src/main/java/org/elasticsearch/index/engine/EngineTestCase.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,10 @@ public static void assertConsistentHistoryBetweenTranslogAndLuceneIndex(Engine e
827827
if (mapper.documentMapper() == null || engine.config().getIndexSettings().isSoftDeleteEnabled() == false) {
828828
return;
829829
}
830+
final long maxSeqNo = ((InternalEngine) engine).getLocalCheckpointTracker().getMaxSeqNo();
831+
if (maxSeqNo < 0) {
832+
return; // nothing to check
833+
}
830834
final Map<Long, Translog.Operation> translogOps = new HashMap<>();
831835
try (Translog.Snapshot snapshot = EngineTestCase.getTranslog(engine).newSnapshot()) {
832836
Translog.Operation op;
@@ -838,7 +842,6 @@ public static void assertConsistentHistoryBetweenTranslogAndLuceneIndex(Engine e
838842
.collect(Collectors.toMap(Translog.Operation::seqNo, Function.identity()));
839843
final long globalCheckpoint = EngineTestCase.getTranslog(engine).getLastSyncedGlobalCheckpoint();
840844
final long retainedOps = engine.config().getIndexSettings().getSoftDeleteRetentionOperations();
841-
long maxSeqNo = Math.max(0, ((InternalEngine)engine).getLocalCheckpointTracker().getMaxSeqNo());
842845
final long seqNoForRecovery;
843846
try (Engine.IndexCommitRef safeCommit = engine.acquireSafeIndexCommit()) {
844847
seqNoForRecovery = Long.parseLong(safeCommit.getIndexCommit().getUserData().get(SequenceNumbers.LOCAL_CHECKPOINT_KEY)) + 1;

0 commit comments

Comments
 (0)