Only pull searcher once during completion stats
The inner call to the completion stats pulled a second searcher that never got released causing the underlying readers to never get closed unless the node is shut down. This was triggered with literally each stats call including the completion stats even if no completion service was used on the index. Closes #3652
This commit is contained in:
parent
7d52d58747
commit
76cc8c3549
|
@ -457,14 +457,14 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
||||||
@Override
|
@Override
|
||||||
public DocsStats docStats() {
|
public DocsStats docStats() {
|
||||||
try {
|
try {
|
||||||
final Engine.Searcher searcher = engine.searcher();
|
final Engine.Searcher searcher = searcher();
|
||||||
try {
|
try {
|
||||||
return new DocsStats(searcher.reader().numDocs(), searcher.reader().numDeletedDocs());
|
return new DocsStats(searcher.reader().numDocs(), searcher.reader().numDeletedDocs());
|
||||||
} finally {
|
} finally {
|
||||||
searcher.release();
|
searcher.release();
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.debug("Can not docStats completion stats from engine shard state [{}]", e, state);
|
logger.debug("Can not build 'doc stats' from engine shard state [{}]", e, state);
|
||||||
return new DocsStats();
|
return new DocsStats();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -489,7 +489,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
||||||
try {
|
try {
|
||||||
return store.stats();
|
return store.stats();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.debug("Can not build store stats from engine shard state [{}]", e, state);
|
logger.debug("Can not build 'store stats' from engine shard state [{}]", e, state);
|
||||||
return new StoreStats();
|
return new StoreStats();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -533,18 +533,18 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
||||||
public CompletionStats completionStats(String... fields) {
|
public CompletionStats completionStats(String... fields) {
|
||||||
CompletionStats completionStats = new CompletionStats();
|
CompletionStats completionStats = new CompletionStats();
|
||||||
try{
|
try{
|
||||||
final Engine.Searcher searcher = engine.searcher();
|
final Engine.Searcher currentSearcher = searcher();
|
||||||
try {
|
try {
|
||||||
PostingsFormat postingsFormat = this.codecService.postingsFormatService().get(Completion090PostingsFormat.CODEC_NAME).get();
|
PostingsFormat postingsFormat = this.codecService.postingsFormatService().get(Completion090PostingsFormat.CODEC_NAME).get();
|
||||||
if (postingsFormat instanceof Completion090PostingsFormat) {
|
if (postingsFormat instanceof Completion090PostingsFormat) {
|
||||||
Completion090PostingsFormat completionPostingsFormat = (Completion090PostingsFormat) postingsFormat;
|
Completion090PostingsFormat completionPostingsFormat = (Completion090PostingsFormat) postingsFormat;
|
||||||
completionStats.add(completionPostingsFormat.completionStats(searcher().reader(), fields));
|
completionStats.add(completionPostingsFormat.completionStats(currentSearcher.reader(), fields));
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
searcher.release();
|
currentSearcher.release();
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.debug("Can not build completion stats from engine shard state [{}]", e, state);
|
logger.debug("Can not build 'completion stats' from engine shard state [{}]", e, state);
|
||||||
// if we are called during engine stop / start or before start we can run into Exceptions
|
// if we are called during engine stop / start or before start we can run into Exceptions
|
||||||
// like the engine is already closed or no saercher is present at this point.
|
// like the engine is already closed or no saercher is present at this point.
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue