Always return false from `refreshNeeded` on ReadOnlyEngine (#35837)

Acquiring a searcher is unnecessary to determine if a refresh is
necessary since read-only engines never refresh.

Closes #35785
This commit is contained in:
Simon Willnauer 2018-11-24 09:25:42 +01:00 committed by GitHub
parent e46e44ce38
commit 4711c5cdf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 4 deletions

View File

@ -1000,7 +1000,7 @@ public abstract class Engine implements Closeable {
*/
public abstract List<Segment> segments(boolean verbose);
public final boolean refreshNeeded() {
public boolean refreshNeeded() {
if (store.tryIncRef()) {
/*
we need to inc the store here since we acquire a searcher and that might keep a file open on the

View File

@ -419,4 +419,9 @@ public class ReadOnlyEngine extends Engine {
protected void processReaders(IndexReader reader, IndexReader previousReader) {
searcherFactory.processReaders(reader, previousReader);
}
@Override
public boolean refreshNeeded() {
return false;
}
}

View File

@ -531,8 +531,7 @@ public class SearchService extends AbstractLifecycleComponent implements IndexEv
long afterQueryTime = System.nanoTime();
operationListener.onQueryPhase(context, afterQueryTime - time);
QueryFetchSearchResult fetchSearchResult = executeFetchPhase(context, operationListener, afterQueryTime);
return new ScrollQueryFetchSearchResult(fetchSearchResult,
context.shardTarget());
return new ScrollQueryFetchSearchResult(fetchSearchResult, context.shardTarget());
} catch (Exception e) {
logger.trace("Fetch phase failed", e);
processFailure(context, e);

View File

@ -207,10 +207,11 @@ public final class FrozenEngine extends ReadOnlyEngine {
assert false : "this is a read-only engine";
case "doc_stats":
assert false : "doc_stats are overwritten";
case "refresh_needed":
assert false : "refresh_needed is always false";
case "segments":
case "segments_stats":
case "completion_stats":
case "refresh_needed":
case "can_match": // special case for can_match phase - we use the cached point values reader
maybeOpenReader = false;
break;