Skip to content

Commit 8159fdf

Browse files
authored
Fix assertion in ReadOnlyEngine (#43010)
We should execute the assertion before throwing an exception; otherwise, it's a noop.
1 parent 4810d3b commit 8159fdf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

server/src/main/java/org/elasticsearch/index/engine/ReadOnlyEngine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,12 @@ protected void ensureMaxSeqNoEqualsToGlobalCheckpoint(final SeqNoStats seqNoStat
141141
final Version indexVersionCreated = engineConfig.getIndexSettings().getIndexVersionCreated();
142142
if (indexVersionCreated.onOrAfter(Version.V_7_2_0) ||
143143
(seqNoStats.getGlobalCheckpoint() != SequenceNumbers.UNASSIGNED_SEQ_NO)) {
144+
assert assertMaxSeqNoEqualsToGlobalCheckpoint(seqNoStats.getMaxSeqNo(), seqNoStats.getGlobalCheckpoint());
144145
if (seqNoStats.getMaxSeqNo() != seqNoStats.getGlobalCheckpoint()) {
145146
throw new IllegalStateException("Maximum sequence number [" + seqNoStats.getMaxSeqNo()
146147
+ "] from last commit does not match global checkpoint [" + seqNoStats.getGlobalCheckpoint() + "]");
147148
}
148149
}
149-
assert assertMaxSeqNoEqualsToGlobalCheckpoint(seqNoStats.getMaxSeqNo(), seqNoStats.getGlobalCheckpoint());
150150
}
151151

152152
protected boolean assertMaxSeqNoEqualsToGlobalCheckpoint(final long maxSeqNo, final long globalCheckpoint) {

0 commit comments

Comments
 (0)