SOLR-173 - fix for 'too many open files' - close requests at end of SolrDispatchFilter, and only get Searcher in response writers if it's actually needed.

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@511970 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris M. Hostetter 2007-02-26 19:42:21 +00:00
parent 69b9438a44
commit 919a3881d0
6 changed files with 21 additions and 8 deletions

View File

@ -167,6 +167,12 @@ Bug Fixes
attempt is made to use the solr.home dir.
(Ryan McKinley via hossman)
6. SOLR-173: Bug fix to SolrDispatchFilter to reduce "too many open
files" problem was that SolrDispatchFilter was not closing requests
when finished. Also modified ResponseWriters to only fetch a Searcher
reference if necessary for writing out DocLists.
(Ryan McKinley via hossman)
Other Changes
1. Updated to Lucene 2.1

View File

@ -24,5 +24,5 @@ for f in $FILES; do
done
#send the commit command to make sure all the changes are flushed and visible
curl $URL --data-binary '<commit/>'
curl $URL --data-binary '<commit/>' -H 'Content-type:text/xml; charset=utf-8'
echo

View File

@ -23,6 +23,7 @@ import org.apache.solr.schema.SchemaField;
import org.apache.solr.schema.TextField;
import org.apache.solr.search.DocIterator;
import org.apache.solr.search.DocList;
import org.apache.solr.search.SolrIndexSearcher;
import org.apache.solr.util.NamedList;
import org.apache.solr.util.SimpleOrderedMap;
@ -427,6 +428,7 @@ class JSONWriter extends TextResponseWriter {
incLevel();
boolean first=true;
SolrIndexSearcher searcher = req.getSearcher();
DocIterator iterator = ids.iterator();
for (int i=0; i<sz; i++) {
int id = iterator.nextDoc();

View File

@ -39,7 +39,6 @@ public abstract class TextResponseWriter {
protected final Writer writer;
protected final IndexSchema schema;
protected final SolrIndexSearcher searcher;
protected final SolrQueryRequest req;
protected final SolrQueryResponse rsp;
@ -53,7 +52,6 @@ public abstract class TextResponseWriter {
public TextResponseWriter(Writer writer, SolrQueryRequest req, SolrQueryResponse rsp) {
this.writer = writer;
this.schema = req.getSchema();
this.searcher = req.getSearcher();
this.req = req;
this.rsp = rsp;
String indent = req.getParam("indent");

View File

@ -82,7 +82,7 @@ final public class XMLWriter {
// and to encapsulate writer, schema, and searcher so
// they don't have to be passed around in every function.
//
XMLWriter xw = new XMLWriter(writer, req.getSchema(), req.getSearcher(), ver);
XMLWriter xw = new XMLWriter(writer, req.getSchema(), req, ver);
xw.defaultFieldList = rsp.getReturnFields();
String indent = req.getParam("indent");
@ -135,7 +135,7 @@ final public class XMLWriter {
private final Writer writer;
private final IndexSchema schema; // needed to write fields of docs
private final SolrIndexSearcher searcher; // needed to retrieve docs
private final SolrQueryRequest request; // the request
private int level;
private boolean defaultIndent=false;
@ -159,10 +159,11 @@ final public class XMLWriter {
private final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
private final StringBuilder sb = new StringBuilder();
public XMLWriter(Writer writer, IndexSchema schema, SolrIndexSearcher searcher, String version) {
public XMLWriter(Writer writer, IndexSchema schema, SolrQueryRequest req, String version) {
this.writer = writer;
this.schema = schema;
this.searcher = searcher;
this.request = req;
float ver = version==null? CURRENT_VERSION : Float.parseFloat(version);
this.version = (int)(ver*1000);
}
@ -357,6 +358,7 @@ final public class XMLWriter {
}
incLevel();
SolrIndexSearcher searcher = request.getSearcher();
DocIterator iterator = ids.iterator();
for (int i=0; i<sz; i++) {
int id = iterator.nextDoc();

View File

@ -74,6 +74,7 @@ public class SolrDispatchFilter implements Filter
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
{
if( request instanceof HttpServletRequest) {
SolrQueryRequest solrReq = null;
HttpServletRequest req = (HttpServletRequest)request;
try {
String path = req.getServletPath();
@ -91,7 +92,6 @@ public class SolrDispatchFilter implements Filter
path = path.substring( 0, idx );
}
SolrQueryRequest solrReq = null;
SolrRequestHandler handler = core.getRequestHandler( path );
if( handler == null && handleSelect ) {
if( "/select".equals( path ) || "/select/".equals( path ) ) {
@ -126,6 +126,11 @@ public class SolrDispatchFilter implements Filter
sendError( (HttpServletResponse)response, ex );
return;
}
finally {
if( solrReq != null ) {
solrReq.close();
}
}
}
// Otherwise let the webapp handle the request