5

My integration tests are failing when I run them from a Gradle task.

org.springframework.data.solr.UncategorizedSolrException: **SolrCore 'collection1' is not available due to init failure: Error opening new searcher; nested exception is org.apache.solr.common.SolrException: SolrCore 'collection1' is not available due to init failure: Error opening new searcher**
at org.springframework.data.solr.core.SolrTemplate.execute(SolrTemplate.java:122)
at org.springframework.data.solr.core.SolrTemplate.saveDocuments(SolrTemplate.java:206)
at org.springframework.data.solr.core.SolrTemplate.saveDocuments(SolrTemplate.java:201)

org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: NativeFSLock@/opt/solr/example/solr/collection1/data/index/write.lock

When I run the integration tests directly in Intellij, the tests run successfully. Here is my bean definition for the embedded server. I added the destroyMethod and it had no effect.

 @Bean(destroyMethod = "shutdown")
public SolrServer solrServer(org.apache.commons.configuration.Configuration configuration)  {

    EmbeddedSolrServerFactory factory;
    try {
        factory = new EmbeddedSolrServerFactory(configuration.getString("solr.home"));
    } catch (ParserConfigurationException | IOException | SAXException e) {
        String errorMsg = "Encountered an exception while initializing the SolrServer bean.";
        log.error(errorMsg, e);
        throw new OrdersClientRuntimeException(errorMsg, e);
    }
    return factory.getSolrServer();
}

Here are the logs. Everything seems to be shutting down correctly.

2014-09-02 17:32:15.757 thread="Thread-6" level="DEBUG" logger="o.s.b.f.s.DisposableBeanAdapter" - **Invoking destroy method 'shutdown' on bean with name 'solrServer'**
2014-09-02 17:32:15.759 thread="Thread-8" level="DEBUG" logger="o.s.b.f.s.DefaultListableBeanFactory" - Retrieved dependent beans for bean 'solrDocumentRepository': [net.nike.orders.client.search.repository.DocumentRepositorySpec]
2014-09-02 17:32:15.759 thread="Thread-6" level="INFO " logger="org.apache.solr.core.CoreContainer" - **Shutting down CoreContainer instance=179265569**
2014-09-02 17:32:15.760 thread="Thread-8" level="DEBUG" logger="o.s.b.f.s.DisposableBeanAdapter" - **Invoking destroy method 'shutdown' on bean with name 'solrServer'**
2014-09-02 17:32:15.760 thread="Thread-8" level="INFO " logger="org.apache.solr.core.CoreContainer" - **Shutting down CoreContainer instance=1604485329**
2014-09-02 17:32:15.762 thread="Thread-6" level="INFO " logger="org.apache.solr.core.SolrCore" - [collection1]  **CLOSING SolrCore** org.apache.solr.core.SolrCore@28da98e2
2014-09-02 17:32:15.769 thread="Thread-8" level="DEBUG" logger="o.a.h.i.c.PoolingClientConnectionManager" - **Connection manager is shutting down**
2014-09-02 17:32:15.769 thread="Thread-6" level="INFO " logger="**org.apache.solr.update.UpdateHandler" - closing** DirectUpdateHandler2{commits=23,autocommit maxTime=15000ms,autocommits=0,soft autocommits=2,optimizes=0,rollbacks=0,expungeDeletes=0,docsPending=0,adds=0,deletesById=0,deletesByQuery=0,errors=0,cumulative_adds=33,cumulative_deletesById=32,cumulative_deletesByQuery=0,cumulative_errors=0,transaction_logs_total_size=5302,transaction_logs_total_number=10}
2014-09-02 17:32:15.771 thread="Thread-8" level="DEBUG" logger="o.a.h.i.c.PoolingClientConnectionManager" - Connection manager shut down
2014-09-02 17:32:15.773 thread="Thread-8" level="DEBUG" logger="o.a.h.i.c.PoolingClientConnectionManager" - Connection manager is shutting down
2014-09-02 17:32:15.774 thread="Thread-8" level="DEBUG" logger="o.a.h.i.c.PoolingClientConnectionManager" - Connection manager shut down

Here is my environment information:

  • Linux Mint 17
  • Solr 4.9.0
  • Solr Test Framework 4.9.0
  • Oracle Java 1.7
  • Spring Data Solr 1.2.2.RELEASE
  • IntelliJ 13.1.4
  • Gradle 1.12
  • Tests are developed in Spock

Any help would be greatly appreciated. Thanks!

kenorb
  • 155,785
  • 88
  • 678
  • 743
Nathan Weddle
  • 187
  • 3
  • 11

3 Answers3

2

I ran into the same thing with my tests but the unlockOnStartup flag didn't work for me. I ended up changing the lock type (and leaving unlockOnStartup commented out):

<lockType>${solr.lock.type:single}</lockType>
<!--<unlockOnStartup>true</unlockOnStartup>-->

The note on the default lock type (native) makes me think that I don't the server shutting down cleany between test runs but I haven't been able to find it yet :(

         native = NativeFSLockFactory - uses OS native file locking.
                  Do not use when multiple solr webapps in the same
                  JVM are attempting to share a single index.
Mike Cantrell
  • 683
  • 6
  • 18
0

Just had a similar issue and got it fixed.

I use the EmbeddedSolrServer in my unit tests and dynamically create new cores during runtime.

When creating the CoreContainer be sure to call shutdown() after the tests.

Also be sure all SolrCore instances are closed after your tests.

Calling coreContainer.create(CoreDescriptor, name, ...) opens a SolrCore which you have to close manually.

When creating the EmbeddedSolrServer by passing the coreName, the SolrCore is not opened! Open and close is handled by the EmbeddedSolrServer for each request/action.

serprime
  • 126
  • 3
  • 9
-1

Ok, so I was able to fix the issue by changing

<unlockOnStartup>true</unlockOnStartup>

in the solrconfig.xml file.

Nathan Weddle
  • 187
  • 3
  • 11