Skip to content

Commit 1929c03

Browse files
committed
Load sequence number statistics from the store
This commit loads sequence number statistics from the store directly when starting the engine instead of indirectly via the index writer.
1 parent 34fbb37 commit 1929c03

File tree

1 file changed

+3
-30
lines changed

1 file changed

+3
-30
lines changed

core/src/main/java/org/elasticsearch/index/engine/InternalEngine.java

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,12 @@ public InternalEngine(EngineConfig engineConfig) throws EngineException {
158158
switch (openMode) {
159159
case OPEN_INDEX_AND_TRANSLOG:
160160
writer = createWriter(false);
161-
seqNoStats = loadSeqNoStatsFromLuceneAndTranslog(engineConfig.getTranslogConfig(), writer);
161+
final long globalCheckpoint = Translog.readGlobalCheckpoint(engineConfig.getTranslogConfig().getTranslogPath());
162+
seqNoStats = store.loadSeqNoStats(globalCheckpoint);
162163
break;
163164
case OPEN_INDEX_CREATE_TRANSLOG:
164165
writer = createWriter(false);
165-
seqNoStats = loadSeqNoStatsFromLucene(SequenceNumbersService.UNASSIGNED_SEQ_NO, writer);
166+
seqNoStats = store.loadSeqNoStats(SequenceNumbersService.UNASSIGNED_SEQ_NO);
166167
break;
167168
case CREATE_INDEX_AND_TRANSLOG:
168169
writer = createWriter(true);
@@ -352,34 +353,6 @@ private Translog.TranslogGeneration loadTranslogIdFromCommit(IndexWriter writer)
352353
return null;
353354
}
354355

355-
/**
356-
* Reads the sequence number stats from the Lucene commit point (maximum sequence number and local checkpoint) and the translog
357-
* checkpoint (global checkpoint).
358-
*
359-
* @param translogConfig the translog config (for the global checkpoint)
360-
* @param indexWriter the index writer (for the Lucene commit point)
361-
* @return the sequence number stats
362-
* @throws IOException if an I/O exception occurred reading the Lucene commit point or the translog checkpoint
363-
*/
364-
private static SeqNoStats loadSeqNoStatsFromLuceneAndTranslog(
365-
final TranslogConfig translogConfig,
366-
final IndexWriter indexWriter) throws IOException {
367-
final long globalCheckpoint = Translog.readGlobalCheckpoint(translogConfig.getTranslogPath());
368-
return loadSeqNoStatsFromLucene(globalCheckpoint, indexWriter);
369-
}
370-
371-
/**
372-
* Reads the sequence number stats from the Lucene commit point (maximum sequence number and local checkpoint) and uses the
373-
* specified global checkpoint.
374-
*
375-
* @param globalCheckpoint the global checkpoint to use
376-
* @param indexWriter the index writer (for the Lucene commit point)
377-
* @return the sequence number stats
378-
*/
379-
private static SeqNoStats loadSeqNoStatsFromLucene(final long globalCheckpoint, final IndexWriter indexWriter) {
380-
return SequenceNumbers.loadSeqNoStatsFromLuceneCommit(globalCheckpoint, indexWriter.getLiveCommitData());
381-
}
382-
383356
private SearcherManager createSearcherManager() throws EngineException {
384357
boolean success = false;
385358
SearcherManager searcherManager = null;

0 commit comments

Comments
 (0)