SOLR-7908: SegmentsInfoRequestHandler gets a ref counted IndexWriter and does not properly release it

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1695069 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2015-08-10 13:51:45 +00:00
parent 42c00ed22b
commit 9c177facb9
2 changed files with 21 additions and 16 deletions

View File

@ -376,6 +376,9 @@ Bug Fixes
* SOLR-7666 (and linked tickets): Many fixes to AngularJS Admin UI bringing it close to feature
parity with existing UI. (Upayavira)
* SOLR-7908: SegmentsInfoRequestHandler gets a ref counted IndexWriter and does not properly release it.
(Mark Miller, shalin)
Optimizations
----------------------

View File

@ -17,6 +17,7 @@ import org.apache.solr.handler.RequestHandlerBase;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.util.RefCounted;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -93,25 +94,26 @@ public class SegmentsInfoRequestHandler extends RequestHandlerBase {
private List<String> getMergeCandidatesNames(SolrQueryRequest req, SegmentInfos infos) throws IOException {
List<String> result = new ArrayList<String>();
IndexWriter indexWriter = getIndexWriter(req);
//get chosen merge policy
MergePolicy mp = indexWriter.getConfig().getMergePolicy();
//Find merges
MergeSpecification findMerges = mp.findMerges(MergeTrigger.EXPLICIT, infos, indexWriter);
if (findMerges != null && findMerges.merges != null && findMerges.merges.size() > 0) {
for (OneMerge merge : findMerges.merges) {
//TODO: add merge grouping
for (SegmentCommitInfo mergeSegmentInfo : merge.segments) {
result.add(mergeSegmentInfo.info.name);
RefCounted<IndexWriter> refCounted = req.getCore().getSolrCoreState().getIndexWriter(req.getCore());
try {
IndexWriter indexWriter = refCounted.get();
//get chosen merge policy
MergePolicy mp = indexWriter.getConfig().getMergePolicy();
//Find merges
MergeSpecification findMerges = mp.findMerges(MergeTrigger.EXPLICIT, infos, indexWriter);
if (findMerges != null && findMerges.merges != null && findMerges.merges.size() > 0) {
for (OneMerge merge : findMerges.merges) {
//TODO: add merge grouping
for (SegmentCommitInfo mergeSegmentInfo : merge.segments) {
result.add(mergeSegmentInfo.info.name);
}
}
}
return result;
} finally {
refCounted.decref();
}
return result;
}
private IndexWriter getIndexWriter(SolrQueryRequest req) throws IOException {
return req.getCore().getSolrCoreState().getIndexWriter(req.getCore()).get();
}
@Override