-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Streamline top level reader close listeners and forbid general usage #14084
Changes from 5 commits
d3436ff
bd5ac9c
ba8de12
dac1799
e3f00e3
1dca0e8
0ead0fa
ec60018
cac073d
7999027
db710c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ | |
import org.elasticsearch.common.lucene.LoggerInfoStream; | ||
import org.elasticsearch.common.lucene.Lucene; | ||
import org.elasticsearch.common.lucene.index.ElasticsearchDirectoryReader; | ||
import org.elasticsearch.common.lucene.index.ElasticsearchLeafReader; | ||
import org.elasticsearch.common.lucene.uid.Versions; | ||
import org.elasticsearch.common.math.MathUtils; | ||
import org.elasticsearch.common.settings.Settings; | ||
|
@@ -905,9 +906,10 @@ private IndexWriter createWriter(boolean create) throws IOException { | |
@Override | ||
public void warm(LeafReader reader) throws IOException { | ||
try { | ||
assert isMergedSegment(reader); | ||
LeafReader esLeafReader = new ElasticsearchLeafReader(reader, shardId); | ||
assert isMergedSegment(esLeafReader); | ||
if (warmer != null) { | ||
final Engine.Searcher searcher = new Searcher("warmer", searcherFactory.newSearcher(reader, null)); | ||
final Engine.Searcher searcher = new Searcher("warmer", searcherFactory.newSearcher(esLeafReader, null)); | ||
final IndicesWarmer.WarmerContext context = new IndicesWarmer.WarmerContext(shardId, searcher); | ||
warmer.warmNewReaders(context); | ||
} | ||
|
@@ -949,6 +951,9 @@ final static class SearchFactory extends EngineSearcherFactory { | |
@Override | ||
public IndexSearcher newSearcher(IndexReader reader, IndexReader previousReader) throws IOException { | ||
IndexSearcher searcher = super.newSearcher(reader, previousReader); | ||
if (reader instanceof LeafReader && isMergedSegment((LeafReader)reader)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when do we call this method with a LeafReader? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. from the merge warmer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you leave a comment to explain this if statement? |
||
return searcher; | ||
} | ||
if (warmer != null) { | ||
// we need to pass a custom searcher that does not release anything on Engine.Search Release, | ||
// we will release explicitly | ||
|
@@ -986,10 +991,11 @@ public IndexSearcher newSearcher(IndexReader reader, IndexReader previousReader) | |
} | ||
|
||
if (newSearcher != null) { | ||
IndicesWarmer.WarmerContext context = new IndicesWarmer.WarmerContext(shardId, new Searcher("warmer", newSearcher)); | ||
IndicesWarmer.WarmerContext context = new IndicesWarmer.WarmerContext(shardId, new Searcher("new_reader_warming", newSearcher)); | ||
warmer.warmNewReaders(context); | ||
} | ||
warmer.warmTopReader(new IndicesWarmer.WarmerContext(shardId, new Searcher("warmer", searcher))); | ||
assert searcher.getIndexReader() instanceof ElasticsearchDirectoryReader : "this class needs an ElasticsearchDirectoryReader but got: " + searcher.getIndexReader().getClass(); | ||
warmer.warmTopReader(new IndicesWarmer.WarmerContext(shardId, new Searcher("top_reader_warming", searcher))); | ||
} catch (Throwable e) { | ||
if (isEngineClosed.get() == false) { | ||
logger.warn("failed to prepare/warm", e); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/an/a/