Yonik, to be more specific, I'm not using a custom request handler. I've just got a Quartz job running periodically inside the Solr webapp that goes out and pulls down updates to Solr from our database. I just expanded the solr .war file and created a custom version with the Spring jars and my own code added in. As for what I did to fix my open file handle issue:
Old code with the stale file handles: public static String getLastTimestamp(String timestampField) throws IOException { Map<String, String[]> args = new HashMap<String, String[]>(); args.put("q", new String[] {"*:*"}); // Query all documents args.put("sort", new String[] {timestampField + " desc"}); // Sort by timestamp, descending args.put("rows", new String[] {"1"}); // Just return the top document SolrCore core = SolrCore.getSolrCore(); SolrQueryRequest request = new LocalSolrQueryRequest(core, args); SolrRequestHandler handler = core.getRequestHandler( request.getQueryType()); SolrQueryResponse response = new SolrQueryResponse(); core.execute(handler, request, response); DocSlice docSlice = (DocSlice) response.getValues().get("response"); SolrIndexSearcher searcher = request.getSearcher(); Integer docId = docSlice.iterator().next(); Set<String> fields = new HashSet<String>(); fields.add(timestampField); // Just return the timestamp field values Document doc = searcher.doc(docId, fields); String timestamp = doc.get(timestampField); return timestamp; } New code: public static String getLastTimestamp(String timestampField) throws IOException { Map<String, String[]> args = new HashMap<String, String[]>(); args.put("q", new String[] {"*:*"}); // Query all documents args.put("sort", new String[] {timestampField + " desc"}); // Sort by timestamp, descending args.put("rows", new String[] {"1"}); // Just return the top document SolrCore core = SolrCore.getSolrCore(); SolrQueryRequest request = new LocalSolrQueryRequest(core, args); SolrRequestHandler handler = core.getRequestHandler( request.getQueryType()); SolrQueryResponse response = new SolrQueryResponse(); core.execute(handler, request, response); DocSlice docSlice = (DocSlice) response.getValues().get("response"); SolrIndexSearcher searcher = request.getSearcher(); Integer docId = docSlice.iterator().next(); Set<String> fields = new HashSet<String>(); fields.add(timestampField); // Just return the timestamp field values Document doc = searcher.doc(docId, fields); String timestamp = doc.get(timestampField); request.close(); searcher.close(); return timestamp; } Mark On Dec 26, 2007 11:26 AM, Yonik Seeley <[EMAIL PROTECTED]> wrote: > On Dec 26, 2007 11:16 AM, Mark Baird <[EMAIL PROTECTED]> wrote: > > Not sure, but I believe I just found the problem. It has to do with the > way > > reference counts are used in the code. Once Yonik mentioned the > reference > > count I looked through the Solr source to see how that worked. Then I > > looked through the custom code I've added to my Solr install and found > an > > instance of SolrQueryRequest that I wasn't calling close() on when done. > > Solr handles all the ref-counting when you use a custom request handler. > Are you using embedded Solr? > > -Yonik >