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:
Any help would be greatly appreciated. Thanks!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With