Solr: unload core wait forever after cores swap

2019-09-05 08:38发布

问题:

I have created a Solr CoreAdminHandler extension with the goal to swap two cores and remove the old one.

My code looks like this:

SolrCore core = coreContainer.create("newcore", coreProps)
coreContainer.swap("newcore", "livecore")
// the old livecore is now newcore, so unload it and remove all the related dirs
coreContainer.unload("newcore", true, true, true)

After the last statement get executed the Solr log starts printing the following messages forever

61424 INFO (pool-1-thread-1) [ x:newcore] o.a.s.c.SolrCore Core newcore is not yet closed, waiting 100 ms before checking again.

I tried to call the close() method on the SolrCore instance before and after the unload but the result is the same.

Any idea? Can this be a Solr bug?

EDIT I have created an issue in Solr jira for this: https://issues.apache.org/jira/browse/SOLR-8757

回答1:

After more than 10 days after opening the issue on the Solr jira I have not get any reply (this is not a good sign for an open source community) so I have spent some time to find a workaround. I basically close the references to the core I want to unload before actually unloading it. Here is the code:

SolrCore core = coreContainer.create("newcore", coreProps)
coreContainer.swap("newcore", "livecore")

// the old livecore is now newcore, so unload it and remove all the related dirs
SolrCore oldCore = coreContainer.getCore("newCore")
while (oldCore.getOpenCount > 1) {
  oldCore.close()
}
coreContainer.unload("newcore", true, true, true)


标签: java solr