You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Jan Van Besien <ja...@ngdata.com> on 2013/10/08 22:38:05 UTC

dynamically adding core with auto-discovery in Solr 4.5

Hi,

We are using auto discovery and have a use case where we want to be
able to add cores dynamically, without restarting solr.

In 4.4 we were able to
- add a directory (e.g. "core1") with an empty core.properties
- call http://localhost:8983/solr/admin/cores?action=CREATE&core=core1&name=core1&instanceDir=%2Fsomewhere%2Fcore1

In 4.5 however this (the second step) fails, saying it cannot create a
new core in that directory because another core is already defined
there.

>From the documentation (http://wiki.apache.org/solr/CoreAdmin), I
understand that since 4.3 we should actually do "RELOAD". However,
RELOAD results in this stacktrace:

org.apache.solr.common.SolrException: Error handling 'reload' action
at org.apache.solr.handler.admin.CoreAdminHandler.handleReloadAction(CoreAdminHandler.java:673)
at org.apache.solr.handler.admin.CoreAdminHandler.handleRequestBody(CoreAdminHandler.java:172)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
at org.apache.solr.servlet.SolrDispatchFilter.handleAdminRequest(SolrDispatchFilter.java:655)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:246)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:195)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:322) at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549) at
org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) at
org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) at
org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: org.apache.solr.common.SolrException: Unable to reload
core: core1 at org.apache.solr.core.CoreContainer.recordAndThrow(CoreContainer.java:936)
at org.apache.solr.core.CoreContainer.reload(CoreContainer.java:691)
at org.apache.solr.handler.admin.CoreAdminHandler.handleReloadAction(CoreAdminHandler.java:671)
... 20 more Caused by: org.apache.solr.common.SolrException: No such
core: core1 at org.apache.solr.core.CoreContainer.reload(CoreContainer.java:642)
... 21 more

Note that before I RELOAD, the core1 directory was created.

Also note that next to the core1 directory, there is a core0 directory
which has exactly the same content and is auto-discovered perfectly
fine at startup.

So... what should it be? Or am I missing something here?

thanks in advance,
Jan

Re: dynamically adding core with auto-discovery in Solr 4.5

Posted by Erick Erickson <er...@gmail.com>.
If you create a Wiki login, I'll be happy to add you to the
contributors list. It's always valuable to have fresh eyes
update docs while the ambiguities are still fresh!

Erick

On Wed, Oct 9, 2013 at 8:37 AM, Jan Van Besien <ja...@ngdata.com> wrote:
> On Wed, Oct 9, 2013 at 2:15 PM, Erick Erickson <er...@gmail.com> wrote:
>> This worked for me if I do NOT have a core.properties at all in my new
>> core. Personally I think the behavior in 4.4 was dangerous, what
>> happens if you mis-type the command for instance? You could do  Bad
>> Things to the old core you were inadvertently re-creating.
>
> Thanks, this works.
>
> I think the documentation could be updated to indicate that
> - auto-discovery is only at startup (that wasn't obvious to me)
> - creating cores after startup should be done on a config directory
> without a core.properties file
>
> Jan

Re: dynamically adding core with auto-discovery in Solr 4.5

Posted by Jan Van Besien <ja...@ngdata.com>.
On Wed, Oct 9, 2013 at 2:15 PM, Erick Erickson <er...@gmail.com> wrote:
> This worked for me if I do NOT have a core.properties at all in my new
> core. Personally I think the behavior in 4.4 was dangerous, what
> happens if you mis-type the command for instance? You could do  Bad
> Things to the old core you were inadvertently re-creating.

Thanks, this works.

I think the documentation could be updated to indicate that
- auto-discovery is only at startup (that wasn't obvious to me)
- creating cores after startup should be done on a config directory
without a core.properties file

Jan

Re: dynamically adding core with auto-discovery in Solr 4.5

Posted by Erick Erickson <er...@gmail.com>.
Jan:

This worked for me if I do NOT have a core.properties at all in my new
core. Personally I think the behavior in 4.4 was dangerous, what
happens if you mis-type the command for instance? You could do  Bad
Things to the old core you were inadvertently re-creating.

The core.properties file gets created in the new core as a results of
the CREATE command. So go ahead and try it again without a
core.properties file perhaps?

The RELOAD command is intended to be used when you change the schema
or solrconfig files and want the core indicated to start working with
the new definitions. It relies on having a record of that core to
work.

When Solr starts up in discovery mode, it explores the directory tree
and keeps an internal map of all the cores, transient, loaded etc. The
reload then looks at that map and barfs if the core isn't there.

Changing this seems like more work than reward, how would the code
know where to look for the core to load? It would have to do a re-walk
of the tree, or rely on instanceDir being an absolute path etc.
Do-able but not worth it IMO.

Best,
Erick

On Tue, Oct 8, 2013 at 4:38 PM, Jan Van Besien <ja...@ngdata.com> wrote:
> Hi,
>
> We are using auto discovery and have a use case where we want to be
> able to add cores dynamically, without restarting solr.
>
> In 4.4 we were able to
> - add a directory (e.g. "core1") with an empty core.properties
> - call http://localhost:8983/solr/admin/cores?action=CREATE&core=core1&name=core1&instanceDir=%2Fsomewhere%2Fcore1
>
> In 4.5 however this (the second step) fails, saying it cannot create a
> new core in that directory because another core is already defined
> there.
>
> From the documentation (http://wiki.apache.org/solr/CoreAdmin), I
> understand that since 4.3 we should actually do "RELOAD". However,
> RELOAD results in this stacktrace:
>
> org.apache.solr.common.SolrException: Error handling 'reload' action
> at org.apache.solr.handler.admin.CoreAdminHandler.handleReloadAction(CoreAdminHandler.java:673)
> at org.apache.solr.handler.admin.CoreAdminHandler.handleRequestBody(CoreAdminHandler.java:172)
> at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
> at org.apache.solr.servlet.SolrDispatchFilter.handleAdminRequest(SolrDispatchFilter.java:655)
> at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:246)
> at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:195)
> at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
> at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
> at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
> at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
> at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
> at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
> at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
> at org.mortbay.jetty.Server.handle(Server.java:322) at
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
> at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
> at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549) at
> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) at
> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) at
> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
> at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
> Caused by: org.apache.solr.common.SolrException: Unable to reload
> core: core1 at org.apache.solr.core.CoreContainer.recordAndThrow(CoreContainer.java:936)
> at org.apache.solr.core.CoreContainer.reload(CoreContainer.java:691)
> at org.apache.solr.handler.admin.CoreAdminHandler.handleReloadAction(CoreAdminHandler.java:671)
> ... 20 more Caused by: org.apache.solr.common.SolrException: No such
> core: core1 at org.apache.solr.core.CoreContainer.reload(CoreContainer.java:642)
> ... 21 more
>
> Note that before I RELOAD, the core1 directory was created.
>
> Also note that next to the core1 directory, there is a core0 directory
> which has exactly the same content and is auto-discovered perfectly
> fine at startup.
>
> So... what should it be? Or am I missing something here?
>
> thanks in advance,
> Jan