我们有一个主从 Solr 设置并仅针对从属运行实时查询。完全导入(优化)每天凌晨 2 点在 master 上进行
# full-import Lists entity
00 02 * * * curl "http://localhost:8080/solr/List/dataimport?command=full-import&clean=true&optimize=true&entity=Lists" > /dev/null
# delta-import Lists entity
*/5 0-1,4-23 * * * curl "http://localhost:8080/solr/List/dataimport?command=delta-import&entity=Lists" > /dev/null
# delta-import ViewedLists entity
23 0-1,4-23 * * * curl "http://localhost:8080/solr/List/dataimport?command=delta-import&entity=ViewedLists" > /dev/null
我们的应用日志中每天都会出现以下异常情况:
...
org.apache.solr.client.solrj.SolrServerException: Error executing query
at org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:95)
at org.apache.solr.client.solrj.SolrServer.query(SolrServer.java:118)
...
像这样的任意查询:
08:26:39,430 ERROR SolrUtil:107 - SOLR QUERY (LIST): q=*:*&fq=-list_type:CONTRIBUTING AND is_source_list:false AND is_blocked_on_hpage:false&start=0&rows=8&sort=first_publish_date desc
org.apache.solr.client.solrj.SolrServerException: java.net.SocketException: Connection reset
at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:478)
at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:244)
at org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:89)
at org.apache.solr.client.solrj.SolrServer.query(SolrServer.java:118)
...
如果我在solr从服务器上查看tomcat中的localhost.log文件,同时出现如下异常:
Apr 06, 2013 7:16:33 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
java.lang.IllegalStateException
at org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:407)
at org.apache.solr.servlet.SolrDispatchFilter.sendError(SolrDispatchFilter.java:389)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:291)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:722)
复制设置如下:
<requestHandler name="/replication" class="solr.ReplicationHandler" >
<lst name="master">
<str name="enable">${enable.master:false}</str>
<str name="replicateAfter">startup</str>
<str name="replicateAfter">commit</str>
<str name="replicateAfter">optimize</str>
<str name="confFiles">solrconfig.xml,data-config.xml,schema.xml,stopwords.txt,synonyms.txt,elevate.xml</str>
</lst>
<lst name="slave">
<str name="enable">${enable.slave:false}</str>
<str name="masterUrl">http://${master.ip}:${master.port}/solr/${solr.core.name}/replication</str>
<str name="pollInterval">00:00:10</str>
</lst>
</requestHandler>
除了完整和增量导入之外,我们还有每 15 分钟加载一次的外部文件字段。在主服务器和从服务器上使用 reloadCache。
是什么导致了这个异常以及如何解决它?
更新:pollInterval
从 10 秒增加到 1 分钟。仍然看到同样的问题。另外,忘记提到该错误在短时间内发生在不同的查询上,因此它不依赖于查询。
更新 2:将增量导入频率降低到每 10 分钟一次,并将外部文件字段加载和 reloadCache 降低到每小时一次。仍然看到异常,尽管异常的频率似乎已经降低。