Solr
  1. Solr
  2. SOLR-5000

ManagedIndexSchema not persist uniqueKey tag after calling addFields method.

    Details

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

      Description

      My co-worker found this one.

      I try to add field via Schema REST API using example-schemaless/solr.
      There is no problem starting sold at first time.
      But restart Jetty, then output this error.

      8385 [qtp620249139-18] ERROR org.apache.solr.servlet.SolrDispatchFilter – null:org.apache.solr.common.SolrException: SolrCore 'collection1' is not available due to init failure: QueryElevationComponent requires the schema to have a uniqueKeyField.
      at org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:971)
      at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:248)
      at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:155)
      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.content(AbstractHttpConnection.java:953)
      at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1014)
      at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:861)
      at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
      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: QueryElevationComponent requires the schema to have a uniqueKeyField.
      at org.apache.solr.core.SolrCore.<init>(SolrCore.java:833)
      at org.apache.solr.core.SolrCore.<init>(SolrCore.java:627)
      at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:733)
      at org.apache.solr.core.CoreContainer.create(CoreContainer.java:768)
      at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:439)
      at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:431)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
      at java.util.concurrent.FutureTask.run(FutureTask.java:166)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
      at java.util.concurrent.FutureTask.run(FutureTask.java:166)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      ... 1 more
      Caused by: org.apache.solr.common.SolrException: QueryElevationComponent requires the schema to have a uniqueKeyField.
      at org.apache.solr.handler.component.QueryElevationComponent.inform(QueryElevationComponent.java:177)
      at org.apache.solr.core.SolrResourceLoader.inform(SolrResourceLoader.java:599)
      at org.apache.solr.core.SolrCore.<init>(SolrCore.java:828)
      ... 13 more

      1. SOLR-5000.patch
        6 kB
        Steve Rowe
      2. SOLR-5000.txt
        2 kB
        Jun Ohtani

        Activity

        Hide
        Jun Ohtani added a comment -

        Maybe the cause of this problem is a private'uniqueKeyFieldName' property in IndexSchema.java.

        Show
        Jun Ohtani added a comment - Maybe the cause of this problem is a private'uniqueKeyFieldName' property in IndexSchema.java.
        Hide
        Steve Rowe added a comment -

        Thanks for reporting, Jun, I can reproduce this, but I'm not sure yet what's happening.

        When ManagedIndexSchema persists to disk or ZooKeeper, it asks parent class IndexSchema to populate a NamedList containing all schema elements, including the unique key field name, and then uses SchemaXmlWriter to convert the NamedList to XML. SchemaXmlWriter looks for the unique key property and appears to do the right thing. So my suspicion at this point is that IndexSchema.uniqueKeyFieldName isn't being populated when the schema is parsed, though IndexSchema.uniqueKeyField obviously must be populated, or else stuff wouldn't work. I'll look into it more later today.

        Show
        Steve Rowe added a comment - Thanks for reporting, Jun, I can reproduce this, but I'm not sure yet what's happening. When ManagedIndexSchema persists to disk or ZooKeeper, it asks parent class IndexSchema to populate a NamedList containing all schema elements, including the unique key field name, and then uses SchemaXmlWriter to convert the NamedList to XML. SchemaXmlWriter looks for the unique key property and appears to do the right thing. So my suspicion at this point is that IndexSchema.uniqueKeyFieldName isn't being populated when the schema is parsed, though IndexSchema.uniqueKeyField obviously must be populated, or else stuff wouldn't work. I'll look into it more later today.
        Hide
        Jun Ohtani added a comment -

        Hi Steve,

        ManagedIndexSchema.shallowCopy method create newSchema instance from 'this'.
        At this time, this method copy only "newSchema.uniqueKeyField = uniqueKeyField", not copy uniqueKeyFieldName and uniqueKeyFieldType.
        Then ManagedIndexSchema persists using newSchema object (uniqueKeyFieldName is null).

        Show
        Jun Ohtani added a comment - Hi Steve, ManagedIndexSchema.shallowCopy method create newSchema instance from 'this'. At this time, this method copy only "newSchema.uniqueKeyField = uniqueKeyField", not copy uniqueKeyFieldName and uniqueKeyFieldType. Then ManagedIndexSchema persists using newSchema object (uniqueKeyFieldName is null).
        Hide
        Jun Ohtani added a comment -

        I create patch but no tests.

        Show
        Jun Ohtani added a comment - I create patch but no tests.
        Hide
        Steve Rowe added a comment -

        Patch with a test, which fails before the rest of the patch is applied and succeeds afterward.

        I made the two IndexSchema data members protected rather than adding a setter for them. No null check on uniqueKeyField is required that way, since setting only happens when it's already known not to be null.

        Committing shortly.

        Show
        Steve Rowe added a comment - Patch with a test, which fails before the rest of the patch is applied and succeeds afterward. I made the two IndexSchema data members protected rather than adding a setter for them. No null check on uniqueKeyField is required that way, since setting only happens when it's already known not to be null. Committing shortly.
        Hide
        ASF subversion and git services added a comment -

        Commit 1499578 from Steve Rowe
        [ https://svn.apache.org/r1499578 ]

        SOLR-5000: ManagedIndexSchema doesn't persist uniqueKey tag after calling addFields method

        Show
        ASF subversion and git services added a comment - Commit 1499578 from Steve Rowe [ https://svn.apache.org/r1499578 ] SOLR-5000 : ManagedIndexSchema doesn't persist uniqueKey tag after calling addFields method
        Hide
        ASF subversion and git services added a comment -

        Commit 1499579 from Steve Rowe
        [ https://svn.apache.org/r1499579 ]

        SOLR-5000: ManagedIndexSchema doesn't persist uniqueKey tag after calling addFields method (merged trunk r1499578)

        Show
        ASF subversion and git services added a comment - Commit 1499579 from Steve Rowe [ https://svn.apache.org/r1499579 ] SOLR-5000 : ManagedIndexSchema doesn't persist uniqueKey tag after calling addFields method (merged trunk r1499578)
        Hide
        Steve Rowe added a comment -

        Committed to trunk and branch_4x.

        Thanks Jun!

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

        Bulk close resolved 4.4 issues

        Show
        Steve Rowe added a comment - Bulk close resolved 4.4 issues

          People

          • Assignee:
            Steve Rowe
            Reporter:
            Jun Ohtani
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development