title: LockObtainFailedException updating Lucene search index using solr
body: <p>I've googled this a lot. Most of these issues are caused by a lock being left around after a JVM crash. This is not my case.</p>
  
  <p>I have an index with multiple readers and writers. I'm am trying to do a mass index update (delete and add -- that's how lucene does updates). I'm using solr's embedded server (org.apache.solr.client.solrj.embedded.EmbeddedSolrServer). Other writers are using the remote, non-streaming server (org.apache.solr.client.solrj.impl.CommonsHttpSolrServer).</p>
  
  <p>I kick off this mass update, it runs fine for a while, then dies with a</p>
  
  <blockquote>
    <p>Caused by:
    org.apache.lucene.store.LockObtainFailedException:
    Lock obtain timed out:
    NativeFSLock@/.../lucene-ff783c5d8800fd9722a95494d07d7e37-write.lock</p>
  </blockquote>
  
  <p>I've adjusted my lock timeouts in solrconfig.xml</p>
  
  <pre><code>&lt;writeLockTimeout&gt;20000&lt;/writeLockTimeout&gt;
  &lt;commitLockTimeout&gt;10000&lt;/commitLockTimeout&gt;
  </code></pre>
  
  <p>I'm about to start reading the lucene code to figure this out. Any help so I don't have to do this would be great!</p>
  
  <p>EDIT: All my updates go through the following code (Scala):</p>
  
  <pre><code>val req = new UpdateRequest
  req.setAction(AbstractUpdateRequest.ACTION.COMMIT, false, false)
  req.add(docs)
  
  val rsp = req.process(solrServer)
  </code></pre>
  
  <p><code>solrServer</code> is an instance of org.apache.solr.client.solrj.impl.CommonsHttpSolrServer, org.apache.solr.client.solrj.impl.StreamingUpdateSolrServer, or org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.</p>
  
  <p>ANOTHER EDIT:
  I stopped using EmbeddedSolrServer and it works now. I have two separate processes that update the solr search index:</p>
  
  <p>1) Servlet
  2) Command line tool</p>
  
  <p>The command line tool was using the EmbeddedSolrServer and it would eventually crash with the LockObtainFailedException. When I started using StreamingUpdateSolrServer, the problems went away.</p>
  
  <p>I'm still a little confused that the EmbeddedSolrServer would work at all. Can someone explain this. I thought that it would play nice with the Servlet process and they would wait while the other is writing.</p>