Skip to content

Commit 6e952c5

Browse files
committed
always check max_seq_no = gcp in readonly engine
1 parent 3959605 commit 6e952c5

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

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

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.apache.lucene.search.SearcherManager;
3131
import org.apache.lucene.store.Directory;
3232
import org.apache.lucene.store.Lock;
33-
import org.elasticsearch.Version;
3433
import org.elasticsearch.common.lucene.Lucene;
3534
import org.elasticsearch.common.lucene.index.ElasticsearchDirectoryReader;
3635
import org.elasticsearch.common.util.concurrent.ReleasableLock;
@@ -123,19 +122,9 @@ public ReadOnlyEngine(EngineConfig config, SeqNoStats seqNoStats, TranslogStats
123122
}
124123

125124
protected void ensureMaxSeqNoEqualsToGlobalCheckpoint(final SeqNoStats seqNoStats) {
126-
// Before 8.0 the global checkpoint is not known and up to date when the engine is created after
127-
// peer recovery, so we only check the max seq no / global checkpoint coherency when the global
128-
// checkpoint is different from the unassigned sequence number value.
129-
// In addition to that we only execute the check if the index the engine belongs to has been
130-
// created after the refactoring of the Close Index API and its TransportVerifyShardBeforeCloseAction
131-
// that guarantee that all operations have been flushed to Lucene.
132-
final Version indexVersionCreated = engineConfig.getIndexSettings().getIndexVersionCreated();
133-
if (indexVersionCreated.onOrAfter(Version.V_7_2_0) ||
134-
(seqNoStats.getGlobalCheckpoint() != SequenceNumbers.UNASSIGNED_SEQ_NO && indexVersionCreated.onOrAfter(Version.V_6_7_0))) {
135-
if (seqNoStats.getMaxSeqNo() != seqNoStats.getGlobalCheckpoint()) {
136-
throw new IllegalStateException("Maximum sequence number [" + seqNoStats.getMaxSeqNo()
137-
+ "] from last commit does not match global checkpoint [" + seqNoStats.getGlobalCheckpoint() + "]");
138-
}
125+
if (seqNoStats.getMaxSeqNo() != seqNoStats.getGlobalCheckpoint()) {
126+
throw new IllegalStateException("Maximum sequence number [" + seqNoStats.getMaxSeqNo()
127+
+ "] from last commit does not match global checkpoint [" + seqNoStats.getGlobalCheckpoint() + "]");
139128
}
140129
assert assertMaxSeqNoEqualsToGlobalCheckpoint(seqNoStats.getMaxSeqNo(), seqNoStats.getGlobalCheckpoint());
141130
}

0 commit comments

Comments
 (0)