Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-8642

SOLR allows creation of collections with invalid names

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 6.0
    • Fix Version/s: 5.5, 6.0
    • Component/s: SolrCloud
    • Labels:
      None

      Description

      Some of my colleagues and I recently noticed that the CREATECOLLECTION API will create a collection even when invalid characters are present in the name.

      For example, consider the following reproduction case, which involves creating a collection with a space in its name:

      $ <clean checkout of SOLR master/trunk>
      $ bin/solr start -e cloud -noprompt
          ...
      $ curl -i -l -k -X GET "http://localhost:8983/solr/admin/collections?action=CREATE&name=getting+started&numShards=2&replicationFactor=2&maxShardsPerNode=2&collection.configName=gettingstarted"
      HTTP/1.1 200 OK
      Content-Type: application/xml; charset=UTF-8
      Transfer-Encoding: chunked
      
      <?xml version="1.0" encoding="UTF-8"?>
      <response>
      <lst name="responseHeader"><int name="status">0</int><int name="QTime">299</int></lst><lst name="failure"><str>org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:Error from server at http://127.0.1.1:8983/solr: Error CREATEing SolrCore 'getting started_shard2_replica2': Unable to create core [getting started_shard2_replica2] Caused by: Invalid core name: 'getting started_shard2_replica2' Names must consist entirely of periods, underscores and alphanumerics</str><str>org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:Error from server at http://127.0.1.1:7574/solr: Error CREATEing SolrCore 'getting started_shard2_replica1': Unable to create core [getting started_shard2_replica1] Caused by: Invalid core name: 'getting started_shard2_replica1' Names must consist entirely of periods, underscores and alphanumerics</str><str>org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:Error from server at http://127.0.1.1:7574/solr: Error CREATEing SolrCore 'getting started_shard1_replica1': Unable to create core [getting started_shard1_replica1] Caused by: Invalid core name: 'getting started_shard1_replica1' Names must consist entirely of periods, underscores and alphanumerics</str><str>org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:Error from server at http://127.0.1.1:8983/solr: Error CREATEing SolrCore 'getting started_shard1_replica2': Unable to create core [getting started_shard1_replica2] Caused by: Invalid core name: 'getting started_shard1_replica2' Names must consist entirely of periods, underscores and alphanumerics</str></lst>
      </response>
      $ 
      $ curl -i -l -k -X GET "http://localhost:8983/solr/admin/collections?action=CLUSTERSTATUS&wt=json&indent=true"
      HTTP/1.1 200 OK
      Content-Type: application/json; charset=UTF-8
      Transfer-Encoding: chunked
      
      {
        "responseHeader":{
          "status":0,
          "QTime":6},
        "cluster":{
          "collections":{
           ...
            "getting started":{
              "replicationFactor":"2",
              "shards":{
                "shard1":{
                  "range":"80000000-ffffffff",
                  "state":"active",
                  "replicas":{}},
                "shard2":{
                  "range":"0-7fffffff",
                  "state":"active",
                  "replicas":{}}},
              "router":{"name":"compositeId"},
              "maxShardsPerNode":"2",
              "autoAddReplicas":"false",
              "znodeVersion":1,
              "configName":"gettingstarted"},
          "live_nodes":["127.0.1.1:8983_solr",
            "127.0.1.1:7574_solr"]}}
      

      The commands/responses above suggest that Solr creates the collection without checking the name. It then goes on to create the cores for the collection, which fails and returns the error seen above.

      I verified this by doing a curl -i -l -k "http://localhost:8983/solr/admin/cores; as expected the cores were not actually created. (This is probably thanks to Erick's work on SOLR-8308).

      This bug is a problem because it will create collections which can never be backed up with actual cores.

      Seems like the same name-verification that 8308 added to cores should also be applied to collections.

        Attachments

        1. SOLR-8642.patch
          12 kB
          Jason Gerlowski
        2. SOLR-8642.patch
          12 kB
          Jason Gerlowski
        3. SOLR-8642.patch
          12 kB
          Jason Gerlowski
        4. SOLR-8642.patch
          12 kB
          Erick Erickson

          Issue Links

            Activity

              People

              • Assignee:
                erickerickson Erick Erickson
                Reporter:
                gerlowskija Jason Gerlowski
              • Votes:
                1 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: