[ 
https://issues.apache.org/jira/browse/SOLR-8642?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15135056#comment-15135056
 ] 

Anshum Gupta commented on SOLR-8642:
------------------------------------

Thanks for the patch Jason.

Here's some feedback:
* Why don't we just throw SolrException from validateCoreName instead?
* In CollectionsHandler, we don't need another wrapper method if we do what 
I've suggested in the point above.
* Just a minor suggestion, can you log the core/collection name in square 
brackets?

The rest looks fine to me.
I am not really familiar with the v2 APIs at this point and haven't looked at 
what needs to change but I can take a look at that as well unless someone who's 
familiar with that confirms that it wouldn't impact v2.

> SOLR allows creation of collections with invalid names
> ------------------------------------------------------
>
>                 Key: SOLR-8642
>                 URL: https://issues.apache.org/jira/browse/SOLR-8642
>             Project: Solr
>          Issue Type: Bug
>          Components: SolrCloud
>    Affects Versions: Trunk
>            Reporter: Jason Gerlowski
>            Priority: Minor
>         Attachments: SOLR-8642.patch
>
>
> 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:
> {code}
> $ <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"]}}
> {code}
> 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.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to