Handling Solr read and write timeout exception

11,464

Commit and Optimize are operations to make updates available to searchers. They are intended to be run after updates, not before queries.

Furthermore, they are expensive operations, which is why you're getting sporadical timeouts. Unless you have some special requirements, I recommend setting the <autoCommit/> option in your solrconfig.xml. As the name says, it will automatically issue the commit depending on configurable criteria like maximum number of uncommitted documents or maximum time after adding documents.

Optimize is even more expensive than Commit, it basically rewrites the index. The frequency of an Optimize depends on how often you Commit changes and how many changes there are per commit.

See also:

Share:
11,464

Related videos on Youtube

azhar_salati
Author by

azhar_salati

I am having total 9 years of web application development experience in the following area - 2 Years of experience in Java, GWT. 3 Years of experience in Java, JSP, Servlets, Javascript. 4 Years of experience in Spring, ExtJs 4.1, ExtJs 5.0, Sencha Touch, D3 JS, Angular JS, HTML5, CSS.

Updated on June 04, 2022

Comments

  • azhar_salati
    azhar_salati almost 2 years

    I am new to solr. I have developed a an website which uses solr for indexing. I want to handle the timeouts that can occur during solr read and write index.Please guide me on how can i handle these exceptions. I am using solrj as solr client and my website and solr server are running on the tomcat.

    Thnak you!

    • Mauricio Scheffer
      Mauricio Scheffer almost 14 years
      When do you get these timeouts? How often are you committing? Check the Solr log, see if there aren't any WARNINGs or ERRORs.
    • azhar_salati
      azhar_salati almost 14 years
      Hi Maurico, Thanks for your interest! I get these timeouts when i am firing a search query.These exceptions are not too often. I am getting the read timeout exception in my tomcat logs as : org.apache.solr.client.solrj.SolrServerException:java.net.So‌​cketTimeoutException‌​: Read timed out at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.requ‌​est(CommonsHttpSolrS‌​erver.java:243) at org.apache.solr.client.solrj.SolrServer.optimize(SolrServer.‌​java:94) at org.apache.solr.client.solrj.SolrServer.optimize(SolrServer.‌​java:82) ..... .....
    • Mauricio Scheffer
      Mauricio Scheffer almost 14 years
      The stack trace says the timeout happens during an optimize operation, not a query... are you optimizing every time you fire a query?
    • azhar_salati
      azhar_salati almost 14 years
      Yes i am optimizing before querrying the solr. Also after the query is fired I am again commiting the server. Should i do this or not?
    • azhar_salati
      azhar_salati almost 14 years
      Hi Mauricio, I tested my code without optimizing the server before firing the query,my prev assumption was wrong.I was not sure whether to optimize it or not.But still can you guide me when to commit the and how often? I am commiting the server when i perform delete or add index to the server.Is it okey?
  • azhar_salati
    azhar_salati almost 14 years
    Thanks a lot Mauricio. I have got all the doubts cleared and have implemented the accordingly.Now i am using only commits when the solr indexes are to be added or removed. Thanks!