mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
Fix assertion in ReadOnlyEngine (#43010)
We should execute the assertion before throwing an exception; otherwise, it's a noop.
This commit is contained in:
parent
915d2f2daa
commit
afe65b5988
@ -141,12 +141,12 @@ public class ReadOnlyEngine extends Engine {
|
|||||||
final Version indexVersionCreated = engineConfig.getIndexSettings().getIndexVersionCreated();
|
final Version indexVersionCreated = engineConfig.getIndexSettings().getIndexVersionCreated();
|
||||||
if (indexVersionCreated.onOrAfter(Version.V_7_2_0) ||
|
if (indexVersionCreated.onOrAfter(Version.V_7_2_0) ||
|
||||||
(seqNoStats.getGlobalCheckpoint() != SequenceNumbers.UNASSIGNED_SEQ_NO && indexVersionCreated.onOrAfter(Version.V_6_7_0))) {
|
(seqNoStats.getGlobalCheckpoint() != SequenceNumbers.UNASSIGNED_SEQ_NO && indexVersionCreated.onOrAfter(Version.V_6_7_0))) {
|
||||||
|
assert assertMaxSeqNoEqualsToGlobalCheckpoint(seqNoStats.getMaxSeqNo(), seqNoStats.getGlobalCheckpoint());
|
||||||
if (seqNoStats.getMaxSeqNo() != seqNoStats.getGlobalCheckpoint()) {
|
if (seqNoStats.getMaxSeqNo() != seqNoStats.getGlobalCheckpoint()) {
|
||||||
throw new IllegalStateException("Maximum sequence number [" + seqNoStats.getMaxSeqNo()
|
throw new IllegalStateException("Maximum sequence number [" + seqNoStats.getMaxSeqNo()
|
||||||
+ "] from last commit does not match global checkpoint [" + seqNoStats.getGlobalCheckpoint() + "]");
|
+ "] from last commit does not match global checkpoint [" + seqNoStats.getGlobalCheckpoint() + "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert assertMaxSeqNoEqualsToGlobalCheckpoint(seqNoStats.getMaxSeqNo(), seqNoStats.getGlobalCheckpoint());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean assertMaxSeqNoEqualsToGlobalCheckpoint(final long maxSeqNo, final long globalCheckpoint) {
|
protected boolean assertMaxSeqNoEqualsToGlobalCheckpoint(final long maxSeqNo, final long globalCheckpoint) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user