6

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!

azhar_salati
  • 1,554
  • 5
  • 28
  • 54
  • When do you get these timeouts? How often are you committing? Check the Solr log, see if there aren't any WARNINGs or ERRORs. – Mauricio Scheffer May 10 '10 at 12:23
  • 1
    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.SocketTimeoutException: Read timed out at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:243) at org.apache.solr.client.solrj.SolrServer.optimize(SolrServer.java:94) at org.apache.solr.client.solrj.SolrServer.optimize(SolrServer.java:82) ..... ..... – azhar_salati May 10 '10 at 12:48
  • The stack trace says the timeout happens during an optimize operation, not a query... are you optimizing every time you fire a query? – Mauricio Scheffer May 10 '10 at 19:03
  • 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 May 11 '10 at 10:14
  • 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 May 11 '10 at 12:30

1 Answers1

11

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:

Community
  • 1
  • 1
Mauricio Scheffer
  • 98,863
  • 23
  • 192
  • 275
  • 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! – azhar_salati May 12 '10 at 08:20