better solr query logging to detect unnecessary sort requests for more

performance profiling
pull/1/head
Michael Peter Christen 11 years ago
parent 338f574bdc
commit a0c53174c5

@ -200,8 +200,9 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo
// during the solr query we set the thread name to the query string to get more debugging info in thread dumps
String q = req.getParams().get("q");
String fq = req.getParams().get("fq");
String sort = req.getParams().get("sor");
String threadname = Thread.currentThread().getName();
if (q != null) Thread.currentThread().setName("solr query: q = " + q + (fq == null ? "" : ", fq = " + fq));
if (q != null) Thread.currentThread().setName("solr query: q = " + q + (fq == null ? "" : ", fq = " + fq) + (sort == null ? "" : ", sort = " + sort)); // for debugging in Threaddump
SolrQueryResponse rsp = new SolrQueryResponse();
NamedList<Object> responseHeader = new SimpleOrderedMap<Object>();
@ -332,8 +333,14 @@ public class EmbeddedSolrConnector extends SolrServerConnector implements SolrCo
public SolrDocumentList getDocumentListByParams(ModifiableSolrParams params) throws IOException, SolrException {
SolrQueryRequest req = this.request(params);
SolrQueryResponse response = null;
String q = params.get("q");
String fq = params.get("fq");
String sort = params.get("sort");
String threadname = Thread.currentThread().getName();
try {
if (q != null) Thread.currentThread().setName("solr query: q = " + q + (fq == null ? "" : ", fq = " + fq) + (sort == null ? "" : ", sort = " + sort)); // for debugging in Threaddump
response = this.query(req);
if (q != null) Thread.currentThread().setName(threadname);
if (response == null) throw new IOException("response == null");
return SolrQueryResponse2SolrDocumentList(req, response);
} finally {

@ -293,26 +293,26 @@ public abstract class SolrServerConnector extends AbstractSolrConnector implemen
// during the solr query we set the thread name to the query string to get more debugging info in thread dumps
String q = params.get("q");
String fq = params.get("fq");
String sort = params.get("sort");
String threadname = Thread.currentThread().getName();
if (q != null) Thread.currentThread().setName("solr query: q = " + q + (fq == null ? "" : ", fq = " + fq));
QueryResponse rsp;
int retry = 100;
int retry = 0;
Throwable error = null;
while (retry-- > 0) {
while (retry++ < 60) {
try {
if (q != null) Thread.currentThread().setName("solr query: q = " + q + (fq == null ? "" : ", fq = " + fq) + (sort == null ? "" : ", sort = " + sort) + "; retry = " + retry); // for debugging in Threaddump
rsp = this.server.query(params);
if (q != null) Thread.currentThread().setName(threadname);
if (rsp != null) if (log.isFine()) log.fine(rsp.getResults().getNumFound() + " results for q=" + q);
return rsp.getResults();
} catch (final SolrServerException e) {
error = e;
clearCaches(); // prevent further OOM if this was caused by OOM
} catch (final Throwable e) {
error = e;
clearCaches(); // prevent further OOM if this was caused by OOM
}
ConcurrentLog.severe("SolrServerConnector", "Failed to query remote Solr: " + error.getMessage() + ", query:" + q + (fq == null ? "" : ", fq = " + fq));
try {Thread.sleep(100);} catch (InterruptedException e) {}
try {Thread.sleep(1000);} catch (InterruptedException e) {}
}
throw new IOException("Error executing query", error);
}

Loading…
Cancel
Save