Skip to content

Commit b9c1f5f

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 8de4659 commit b9c1f5f

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
@@ -838,6 +838,10 @@ public static void assertConsistentHistoryBetweenTranslogAndLuceneIndex(Engine e
838838
if (mapper.types().isEmpty() || engine.config().getIndexSettings().isSoftDeleteEnabled() == false) {
839839
return;
840840
}
841+
final long maxSeqNo = ((InternalEngine) engine).getLocalCheckpointTracker().getMaxSeqNo();
842+
if (maxSeqNo < 0) {
843+
return; // nothing to check
844+
}
841845
final Map<Long, Translog.Operation> translogOps = new HashMap<>();
842846
try (Translog.Snapshot snapshot = EngineTestCase.getTranslog(engine).newSnapshot()) {
843847
Translog.Operation op;
@@ -849,7 +853,6 @@ public static void assertConsistentHistoryBetweenTranslogAndLuceneIndex(Engine e
849853
.collect(Collectors.toMap(Translog.Operation::seqNo, Function.identity()));
850854
final long globalCheckpoint = EngineTestCase.getTranslog(engine).getLastSyncedGlobalCheckpoint();
851855
final long retainedOps = engine.config().getIndexSettings().getSoftDeleteRetentionOperations();
852-
long maxSeqNo = Math.max(0, ((InternalEngine)engine).getLocalCheckpointTracker().getMaxSeqNo());
853856
final long seqNoForRecovery;
854857
try (Engine.IndexCommitRef safeCommit = engine.acquireSafeIndexCommit()) {
855858
seqNoForRecovery = Long.parseLong(safeCommit.getIndexCommit().getUserData().get(SequenceNumbers.LOCAL_CHECKPOINT_KEY)) + 1;

0 commit comments

Comments
 (0)