Description
In SolrJ, using the interface available for making COLSTATUS collection calls will return the collection status for all collections on the cluster as opposed to just one when specifying the collection.
The API in question is CollectionAdminRequest.collectionStatus(collection) in the class CollectionAdminRequest.java]. This will create and return a new CollectionAdminRequest#ColStatus instance that extends AsyncCollectionSpecificAdminRequest.
The constructor of that class will pass the collection passed in to the parent] class and keep it in a param “collection”.
When we call AsyncCollectionSpecificAdminRequest.getParams(), we return:
@Override public SolrParams getParams() { ModifiableSolrParams params = new ModifiableSolrParams(super.getParams()); params.set(CoreAdminParams.NAME, collection); params.setNonNull(CollectionAdminParams.FOLLOW_ALIASES, followAliases); return params; }
With “name” set to the collection name. In CollectionsHandler where Solr handles the collection API operation request, it only copies the follow params if they exist into a new map of properties. Notice how it is missing “name” so we'll never copy that param even if it's included.
We then call ColStatus.java#getColStatus in the same block, getColStatus method will try to retrieve "collection" but will always return null since it's not used in the solrj interfaces and therefore grab the status from all collections vs the one specified when using solrj.
String col = props.getStr(ZkStateReader.COLLECTION_PROP); if (col == null) { collections = new HashSet<>(clusterState.getCollectionsMap().keySet()); } else { collections = Collections.singleton(col); }
This is unfortunate as the command will send a request to every leader replica per collection when that was not the intention.
This can be reproduced by spinning up a cluster with 2+ collections and a short snippet of code which will return the status for all collections as opposed to one:
String host = "http://localhost:8983/solr"; HttpSolrClient.Builder builder = new HttpSolrClient.Builder(host); HttpSolrClient solrClient = builder.build(); String collection = "test"; final NamedList<Object> response = solrClient.request(CollectionAdminRequest.collectionStatus(collection)); System.out.println(response);
I think the simplest fix is to just add "NAME" to the list of params that get copied in CollectionsHandler and can try that a bit later.
Attachments
Issue Links
- links to