Rename IndexShard#searcher() to #acquireSearcher()
Based on recent bugs ( #3652 ) where searchers were acquired multiple times but never released 'IndexShard#searcher()' has not a more accurate name. Closes #3653
This commit is contained in:
parent
777d7f47a5
commit
5c00dc5773
|
@ -157,7 +157,7 @@ public class TransportIndicesStatusAction extends TransportBroadcastOperationAct
|
|||
// shardStatus.estimatedFlushableMemorySize = indexShard.estimateFlushableMemorySize();
|
||||
shardStatus.translogId = indexShard.translog().currentId();
|
||||
shardStatus.translogOperations = indexShard.translog().estimatedNumberOfOperations();
|
||||
Engine.Searcher searcher = indexShard.searcher();
|
||||
Engine.Searcher searcher = indexShard.acquireSearcher();
|
||||
try {
|
||||
shardStatus.docs = new DocsStatus();
|
||||
shardStatus.docs.numDocs = searcher.reader().numDocs();
|
||||
|
|
|
@ -172,7 +172,7 @@ public class TransportValidateQueryAction extends TransportBroadcastOperationAct
|
|||
} else {
|
||||
SearchContext.setCurrent(new DefaultSearchContext(0,
|
||||
new ShardSearchRequest().types(request.types()),
|
||||
null, indexShard.searcher(), indexService, indexShard,
|
||||
null, indexShard.acquireSearcher(), indexService, indexShard,
|
||||
scriptService, cacheRecycler));
|
||||
try {
|
||||
ParsedQuery parsedQuery = queryParserService.parse(request.querySource());
|
||||
|
|
|
@ -154,7 +154,7 @@ public class TransportCountAction extends TransportBroadcastOperationAction<Coun
|
|||
SearchShardTarget shardTarget = new SearchShardTarget(clusterService.localNode().id(), request.index(), request.shardId());
|
||||
SearchContext context = new DefaultSearchContext(0,
|
||||
new ShardSearchRequest().types(request.types()).filteringAliases(request.filteringAliases()),
|
||||
shardTarget, indexShard.searcher(), indexService, indexShard,
|
||||
shardTarget, indexShard.acquireSearcher(), indexService, indexShard,
|
||||
scriptService, cacheRecycler);
|
||||
SearchContext.setCurrent(context);
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ public class TransportSuggestAction extends TransportBroadcastOperationAction<Su
|
|||
protected ShardSuggestResponse shardOperation(ShardSuggestRequest request) throws ElasticSearchException {
|
||||
IndexService indexService = indicesService.indexServiceSafe(request.index());
|
||||
IndexShard indexShard = indexService.shardSafe(request.shardId());
|
||||
final Engine.Searcher searcher = indexShard.searcher();
|
||||
final Engine.Searcher searcher = indexShard.acquireSearcher();
|
||||
XContentParser parser = null;
|
||||
try {
|
||||
BytesReference suggest = request.suggest();
|
||||
|
|
|
@ -227,7 +227,7 @@ public class PercolatorQueriesRegistry extends AbstractIndexShardComponent {
|
|||
private void loadQueries(IndexShard shard) {
|
||||
try {
|
||||
shard.refresh(new Engine.Refresh().force(true));
|
||||
Engine.Searcher searcher = shard.searcher();
|
||||
Engine.Searcher searcher = shard.acquireSearcher();
|
||||
try {
|
||||
Query query = new XConstantScoreQuery(
|
||||
indexCache.filter().cache(
|
||||
|
|
|
@ -136,7 +136,7 @@ public interface IndexShard extends IndexShardComponent {
|
|||
|
||||
void recover(Engine.RecoveryHandler recoveryHandler) throws EngineException;
|
||||
|
||||
Engine.Searcher searcher();
|
||||
Engine.Searcher acquireSearcher();
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this shard can ignore a recovery attempt made to it (since the already doing/done it)
|
||||
|
|
|
@ -457,7 +457,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
|||
@Override
|
||||
public DocsStats docStats() {
|
||||
try {
|
||||
final Engine.Searcher searcher = searcher();
|
||||
final Engine.Searcher searcher = acquireSearcher();
|
||||
try {
|
||||
return new DocsStats(searcher.reader().numDocs(), searcher.reader().numDeletedDocs());
|
||||
} finally {
|
||||
|
@ -533,7 +533,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
|||
public CompletionStats completionStats(String... fields) {
|
||||
CompletionStats completionStats = new CompletionStats();
|
||||
try{
|
||||
final Engine.Searcher currentSearcher = searcher();
|
||||
final Engine.Searcher currentSearcher = acquireSearcher();
|
||||
try {
|
||||
PostingsFormat postingsFormat = this.codecService.postingsFormatService().get(Completion090PostingsFormat.CODEC_NAME).get();
|
||||
if (postingsFormat instanceof Completion090PostingsFormat) {
|
||||
|
@ -591,7 +591,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
|||
}
|
||||
|
||||
@Override
|
||||
public Engine.Searcher searcher() {
|
||||
public Engine.Searcher acquireSearcher() {
|
||||
readAllowed();
|
||||
return engine.searcher();
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class ShardTermVectorService extends AbstractIndexShardComponent {
|
|||
}
|
||||
|
||||
public TermVectorResponse getTermVector(TermVectorRequest request) {
|
||||
final Engine.Searcher searcher = indexShard.searcher();
|
||||
final Engine.Searcher searcher = indexShard.acquireSearcher();
|
||||
IndexReader topLevelReader = searcher.reader();
|
||||
final TermVectorResponse termVectorResponse = new TermVectorResponse(request.index(), request.type(), request.id());
|
||||
final Term uidTerm = new Term(UidFieldMapper.NAME, Uid.createUidAsBytes(request.type(), request.id()));
|
||||
|
|
|
@ -179,7 +179,7 @@ public class IndicesTTLService extends AbstractLifecycleComponent<IndicesTTLServ
|
|||
private void purgeShards(List<IndexShard> shardsToPurge) {
|
||||
for (IndexShard shardToPurge : shardsToPurge) {
|
||||
Query query = NumericRangeQuery.newLongRange(TTLFieldMapper.NAME, null, System.currentTimeMillis(), false, true);
|
||||
Engine.Searcher searcher = shardToPurge.searcher();
|
||||
Engine.Searcher searcher = shardToPurge.acquireSearcher();
|
||||
try {
|
||||
logger.debug("[{}][{}] purging shard", shardToPurge.routingEntry().index(), shardToPurge.routingEntry().id());
|
||||
ExpiredDocsCollector expiredDocsCollector = new ExpiredDocsCollector(shardToPurge.routingEntry().index());
|
||||
|
|
|
@ -416,7 +416,7 @@ public class PercolatorService extends AbstractComponent {
|
|||
@Override
|
||||
public PercolateShardResponse doPercolate(PercolateShardRequest request, PercolateContext context) {
|
||||
long count = 0;
|
||||
Engine.Searcher percolatorSearcher = context.indexShard().searcher();
|
||||
Engine.Searcher percolatorSearcher = context.indexShard().acquireSearcher();
|
||||
try {
|
||||
Count countCollector = count(logger, context);
|
||||
queryBasedPercolating(percolatorSearcher, context, countCollector);
|
||||
|
@ -515,7 +515,7 @@ public class PercolatorService extends AbstractComponent {
|
|||
|
||||
@Override
|
||||
public PercolateShardResponse doPercolate(PercolateShardRequest request, PercolateContext context) {
|
||||
Engine.Searcher percolatorSearcher = context.indexShard().searcher();
|
||||
Engine.Searcher percolatorSearcher = context.indexShard().acquireSearcher();
|
||||
try {
|
||||
Match match = match(logger, context, highlightPhase);
|
||||
queryBasedPercolating(percolatorSearcher, context, match);
|
||||
|
@ -548,7 +548,7 @@ public class PercolatorService extends AbstractComponent {
|
|||
|
||||
@Override
|
||||
public PercolateShardResponse doPercolate(PercolateShardRequest request, PercolateContext context) {
|
||||
Engine.Searcher percolatorSearcher = context.indexShard().searcher();
|
||||
Engine.Searcher percolatorSearcher = context.indexShard().acquireSearcher();
|
||||
try {
|
||||
MatchAndScore matchAndScore = matchAndScore(logger, context, highlightPhase);
|
||||
queryBasedPercolating(percolatorSearcher, context, matchAndScore);
|
||||
|
@ -658,7 +658,7 @@ public class PercolatorService extends AbstractComponent {
|
|||
|
||||
@Override
|
||||
public PercolateShardResponse doPercolate(PercolateShardRequest request, PercolateContext context) {
|
||||
Engine.Searcher percolatorSearcher = context.indexShard().searcher();
|
||||
Engine.Searcher percolatorSearcher = context.indexShard().acquireSearcher();
|
||||
try {
|
||||
MatchAndSort matchAndSort = QueryCollector.matchAndSort(logger, context);
|
||||
queryBasedPercolating(percolatorSearcher, context, matchAndSort);
|
||||
|
|
|
@ -456,7 +456,7 @@ public class SearchService extends AbstractLifecycleComponent<SearchService> {
|
|||
|
||||
SearchShardTarget shardTarget = new SearchShardTarget(clusterService.localNode().id(), request.index(), request.shardId());
|
||||
|
||||
Engine.Searcher engineSearcher = searcher == null ? indexShard.searcher() : searcher;
|
||||
Engine.Searcher engineSearcher = searcher == null ? indexShard.acquireSearcher() : searcher;
|
||||
SearchContext context = new DefaultSearchContext(idGenerator.incrementAndGet(), request, shardTarget, engineSearcher, indexService, indexShard, scriptService, cacheRecycler);
|
||||
SearchContext.setCurrent(context);
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue