Solr
  1. Solr
  2. SOLR-5119

Managed schema problems after adding fields via Schema Rest API

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 4.4
    • Fix Version/s: 4.5, 6.0
    • Component/s: Schema and Analysis
    • Labels:
      None

      Description

      After adding fields with the Schema API the schema cannot be shown on the Admin UI anymore and reloading the Collection/Core throws an NullPointerException. The schema itself seems to work.

      Steps to reproduce:

      1. enable managed schema in example/solr/collection1/conf/solrconfig.xml

      2. upload that config

      sh example/cloud-scripts/zkcli.sh -z localhost:8575 -cmd upconfig -d example/solr/collection1/conf/ -n myconfig

      3. create a new collection

      curl "http://localhost:8983/solr/admin/collections?action=CREATE&name=mycollection&numShards=1&replicationFactor=1&collection.configName=myconfig"

      4. add some fields

      curl http://localhost:8983/solr/mycollection/schema/fields -X POST -H 'Content-type:application/json' --data-binary '[
      {
        "name": "my_field",
        "type": "string",
        "stored": true,
        "indexed": true
      },
      {
        "name": "my_field2",
        "type": "string",
        "stored": true,
        "indexed": true
      }
      ]'

      5. Problem 1: http://localhost:8983/solr/#/mycollection_shard1_replica1/schema

      <?xml version="1.0" encoding="UTF-8"?>
      <response>
      <lst name="responseHeader"><int name="status">404</int><int name="QTime">2</int></lst><lst name="error"><str name="msg">Can not find: /configs/myconfig/null</str><int name="code">404</int></lst>
      </response>
      

      6. Problem 2: http://localhost:8983/solr/admin/collections?action=RELOAD&name=mycollection

      <response>
      <lst name="responseHeader"><int name="status">0</int><int name="QTime">845</int></lst><lst name="failure"><str name="10.147.252.2:8983_solr">org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException:Server at http://10.147.252.2:8983/solr returned non ok status:500, message:Server Error</str></lst>
      </response>
      

      7. when restarting Solr, both 5 and 6 work

        Activity

        Hide
        Steve Rowe added a comment -

        I was able to reproduce both problems, in standalone mode and in SolrCloud mode.

        Steps to reproduce in standalone mode: start the example in managed schema mode; add one or more fields via the REST API (e.g. the curl add fields command given in the description), then either reload the core or view the schema from the admin UI.

        The source of both problems is the same: ManagedIndexSchema.shallowCopy() doesn't set resourceName at all, and then when it's referenced an NPE occurs:

        382354 [qtp1973711593-30] INFO  org.apache.solr.servlet.SolrDispatchFilter  – [admin] webapp=null path=/admin/cores params={action=RELOAD&_=1376332774482&core=collection1&wt=json} status=500 QTime=195 
        382355 [qtp1973711593-30] ERROR org.apache.solr.servlet.SolrDispatchFilter  – null:org.apache.solr.common.SolrException: Error handling 'reload' action
        	at org.apache.solr.handler.admin.CoreAdminHandler.handleReloadAction(CoreAdminHandler.java:671)
        	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:618)
        	at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:209)
        	at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:158)
        	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)
        	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
        	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
        	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
        	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
        	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
        	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
        	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
        	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
        	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
        	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
        	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
        	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
        	at org.eclipse.jetty.server.Server.handle(Server.java:368)
        	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
        	at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)
        	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:942)
        	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1004)
        	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:640)
        	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
        	at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)
        	at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)
        	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
        	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
        	at java.lang.Thread.run(Thread.java:724)
        Caused by: org.apache.solr.common.SolrException: Unable to reload core: collection1
        	at org.apache.solr.core.CoreContainer.recordAndThrow(CoreContainer.java:930)
        	at org.apache.solr.core.CoreContainer.reload(CoreContainer.java:685)
        	at org.apache.solr.handler.admin.CoreAdminHandler.handleReloadAction(CoreAdminHandler.java:669)
        	... 30 more
        Caused by: java.lang.NullPointerException
        	at org.apache.solr.schema.ManagedIndexSchemaFactory.warnIfNonManagedSchemaExists(ManagedIndexSchemaFactory.java:222)
        	at org.apache.solr.schema.ManagedIndexSchemaFactory.readSchemaLocally(ManagedIndexSchemaFactory.java:197)
        	at org.apache.solr.schema.ManagedIndexSchemaFactory.create(ManagedIndexSchemaFactory.java:118)
        	at org.apache.solr.schema.ManagedIndexSchemaFactory.create(ManagedIndexSchemaFactory.java:45)
        	at org.apache.solr.schema.IndexSchemaFactory.buildIndexSchema(IndexSchemaFactory.java:69)
        	at org.apache.solr.core.SolrCore.reload(SolrCore.java:404)
        	at org.apache.solr.core.CoreContainer.reload(CoreContainer.java:675)
        	... 31 more
        

        From ManagedIndexSchemaFactory.warnIfNonManagedSchemaExists():

        221:  private void warnIfNonManagedSchemaExists() {
        222:    if ( ! resourceName.equals(managedSchemaResourceName)) {
        
        Show
        Steve Rowe added a comment - I was able to reproduce both problems, in standalone mode and in SolrCloud mode. Steps to reproduce in standalone mode: start the example in managed schema mode; add one or more fields via the REST API (e.g. the curl add fields command given in the description), then either reload the core or view the schema from the admin UI. The source of both problems is the same: ManagedIndexSchema.shallowCopy() doesn't set resourceName at all, and then when it's referenced an NPE occurs: 382354 [qtp1973711593-30] INFO org.apache.solr.servlet.SolrDispatchFilter – [admin] webapp=null path=/admin/cores params={action=RELOAD&_=1376332774482&core=collection1&wt=json} status=500 QTime=195 382355 [qtp1973711593-30] ERROR org.apache.solr.servlet.SolrDispatchFilter – null:org.apache.solr.common.SolrException: Error handling 'reload' action at org.apache.solr.handler.admin.CoreAdminHandler.handleReloadAction(CoreAdminHandler.java:671) 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:618) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:209) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:158) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) at org.eclipse.jetty.server.Server.handle(Server.java:368) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489) at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53) at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:942) at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1004) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:640) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235) at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72) at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) at java.lang.Thread.run(Thread.java:724) Caused by: org.apache.solr.common.SolrException: Unable to reload core: collection1 at org.apache.solr.core.CoreContainer.recordAndThrow(CoreContainer.java:930) at org.apache.solr.core.CoreContainer.reload(CoreContainer.java:685) at org.apache.solr.handler.admin.CoreAdminHandler.handleReloadAction(CoreAdminHandler.java:669) ... 30 more Caused by: java.lang.NullPointerException at org.apache.solr.schema.ManagedIndexSchemaFactory.warnIfNonManagedSchemaExists(ManagedIndexSchemaFactory.java:222) at org.apache.solr.schema.ManagedIndexSchemaFactory.readSchemaLocally(ManagedIndexSchemaFactory.java:197) at org.apache.solr.schema.ManagedIndexSchemaFactory.create(ManagedIndexSchemaFactory.java:118) at org.apache.solr.schema.ManagedIndexSchemaFactory.create(ManagedIndexSchemaFactory.java:45) at org.apache.solr.schema.IndexSchemaFactory.buildIndexSchema(IndexSchemaFactory.java:69) at org.apache.solr.core.SolrCore.reload(SolrCore.java:404) at org.apache.solr.core.CoreContainer.reload(CoreContainer.java:675) ... 31 more From ManagedIndexSchemaFactory.warnIfNonManagedSchemaExists() : 221: private void warnIfNonManagedSchemaExists() { 222: if ( ! resourceName.equals(managedSchemaResourceName)) {
        Hide
        Steve Rowe added a comment -

        Trivial patch, makes ManagedIndexSchema.shallowCopy() set resourceName to managedSchemaResourceName; also adds a test that reloads the core after adding a field in managed schema mode, which fails before the patch and succeeds after.

        Committing shortly.

        Show
        Steve Rowe added a comment - Trivial patch, makes ManagedIndexSchema.shallowCopy() set resourceName to managedSchemaResourceName ; also adds a test that reloads the core after adding a field in managed schema mode, which fails before the patch and succeeds after. Committing shortly.
        Hide
        ASF subversion and git services added a comment -

        Commit 1513238 from Steve Rowe in branch 'dev/trunk'
        [ https://svn.apache.org/r1513238 ]

        SOLR-5119: Managed schema problems after adding fields via Schema Rest API

        Show
        ASF subversion and git services added a comment - Commit 1513238 from Steve Rowe in branch 'dev/trunk' [ https://svn.apache.org/r1513238 ] SOLR-5119 : Managed schema problems after adding fields via Schema Rest API
        Hide
        ASF subversion and git services added a comment -

        Commit 1513240 from Steve Rowe in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1513240 ]

        SOLR-5119: Managed schema problems after adding fields via Schema Rest API (merged trunk r1513238)

        Show
        ASF subversion and git services added a comment - Commit 1513240 from Steve Rowe in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1513240 ] SOLR-5119 : Managed schema problems after adding fields via Schema Rest API (merged trunk r1513238)
        Hide
        Steve Rowe added a comment -

        Committed to trunk and branch_4x.

        Thanks Nils!

        Show
        Steve Rowe added a comment - Committed to trunk and branch_4x. Thanks Nils!
        Hide
        Adrien Grand added a comment -

        4.5 release -> bulk close

        Show
        Adrien Grand added a comment - 4.5 release -> bulk close

          People

          • Assignee:
            Steve Rowe
            Reporter:
            NilsK
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development