3030import org .apache .lucene .search .SearcherManager ;
3131import org .apache .lucene .store .Directory ;
3232import org .apache .lucene .store .Lock ;
33+ import org .elasticsearch .Assertions ;
3334import org .elasticsearch .Version ;
3435import org .elasticsearch .common .lucene .Lucene ;
3536import org .elasticsearch .common .lucene .index .ElasticsearchDirectoryReader ;
@@ -111,7 +112,7 @@ public ReadOnlyEngine(EngineConfig config, SeqNoStats seqNoStats, TranslogStats
111112 if (globalCheckpoint != SequenceNumbers .UNASSIGNED_SEQ_NO
112113 && engineConfig .getIndexSettings ().getIndexVersionCreated ().onOrAfter (Version .V_6_7_0 )) {
113114 if (seqNoStats .getMaxSeqNo () != globalCheckpoint ) {
114- assert false : "max seq. no. [" + seqNoStats .getMaxSeqNo () + "] does not match [" + globalCheckpoint + "]" ;
115+ assertMaxSeqNoEqualsToGlobalCheckpoint ( seqNoStats .getMaxSeqNo (), globalCheckpoint ) ;
115116 throw new IllegalStateException ("Maximum sequence number [" + seqNoStats .getMaxSeqNo ()
116117 + "] from last commit does not match global checkpoint [" + globalCheckpoint + "]" );
117118 }
@@ -135,6 +136,12 @@ public ReadOnlyEngine(EngineConfig config, SeqNoStats seqNoStats, TranslogStats
135136 }
136137 }
137138
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+
138145 protected final DirectoryReader wrapReader (DirectoryReader reader ,
139146 Function <DirectoryReader , DirectoryReader > readerWrapperFunction ) throws IOException {
140147 reader = ElasticsearchDirectoryReader .wrap (reader , engineConfig .getShardId ());
0 commit comments