30
30
import org .apache .lucene .search .SearcherManager ;
31
31
import org .apache .lucene .store .Directory ;
32
32
import org .apache .lucene .store .Lock ;
33
+ import org .elasticsearch .Assertions ;
33
34
import org .elasticsearch .Version ;
34
35
import org .elasticsearch .common .lucene .Lucene ;
35
36
import org .elasticsearch .common .lucene .index .ElasticsearchDirectoryReader ;
@@ -111,7 +112,7 @@ public ReadOnlyEngine(EngineConfig config, SeqNoStats seqNoStats, TranslogStats
111
112
if (globalCheckpoint != SequenceNumbers .UNASSIGNED_SEQ_NO
112
113
&& engineConfig .getIndexSettings ().getIndexVersionCreated ().onOrAfter (Version .V_6_7_0 )) {
113
114
if (seqNoStats .getMaxSeqNo () != globalCheckpoint ) {
114
- assert false : "max seq. no. [" + seqNoStats .getMaxSeqNo () + "] does not match [" + globalCheckpoint + "]" ;
115
+ assertMaxSeqNoEqualsToGlobalCheckpoint ( seqNoStats .getMaxSeqNo (), globalCheckpoint ) ;
115
116
throw new IllegalStateException ("Maximum sequence number [" + seqNoStats .getMaxSeqNo ()
116
117
+ "] from last commit does not match global checkpoint [" + globalCheckpoint + "]" );
117
118
}
@@ -135,6 +136,12 @@ public ReadOnlyEngine(EngineConfig config, SeqNoStats seqNoStats, TranslogStats
135
136
}
136
137
}
137
138
139
+ protected void assertMaxSeqNoEqualsToGlobalCheckpoint (final long maxSeqNo , final long globalCheckpoint ) {
140
+ if (Assertions .ENABLED ) {
141
+ assert false : "max seq. no. [" + maxSeqNo + "] does not match [" + globalCheckpoint + "]" ;
142
+ }
143
+ }
144
+
138
145
protected final DirectoryReader wrapReader (DirectoryReader reader ,
139
146
Function <DirectoryReader , DirectoryReader > readerWrapperFunction ) throws IOException {
140
147
reader = ElasticsearchDirectoryReader .wrap (reader , engineConfig .getShardId ());
0 commit comments