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

Chris M. Hostetter commented on SOLR-17866:
-------------------------------------------

I discovered this while upgrading a custom plugin code base from Solr 9.6.1 to 
Solr 9.9.0. 

I have a lot of code that looks like the examples below (rewritten in the form 
of a sample test case)...
{code:java}
  private static GenericSolrRequest makeReq() {
    return new GenericSolrRequest(SolrRequest.METHOD.GET,
                                  "/select", // could be anything
                                  
params("_trace","test-check","distrib","false"));
  }

  @Test
  public void testGenericProcessRandomJettyClient() throws Exception {
    try (SolrClient jettyClient = cluster.getRandomJetty(random()).newClient()) 
{
      final GenericSolrRequest req = makeReq();
      req.setRequiresCollection(true);
      final SimpleSolrResponse rsp = req.process(jettyClient, COLLECTION_NAME);
      // TODO: ... make some assertions about rsp ...
    }
  }
  @Test
  public void testGenericProcessReplicaSpecificJettyClient() throws Exception {
    // We want to send requests to an explicit replica,
    // here it's the leader of our single shard...
    final Replica leaderReplica =
      getCollectionState(COLLECTION_NAME)
      .getActiveSlicesArr()[0]
      .getLeader();
    try (SolrClient leaderClient = 
cluster.getReplicaJetty(leaderReplica).newClient()) {
      final GenericSolrRequest req = makeReq();
      req.setRequiresCollection(true);
      final SimpleSolrResponse rsp = req.process(leaderClient, 
leaderReplica.getCoreName());
      // TODO: ... make some assertions about rsp ...
    }
  }
{code}
 

...and found that these types of requests (to any replica on a specific node, 
or two a specific replica on a specific node) would fail with...
{noformat}
 <title>Error 404 Can not find: /solr/select< /title>
{noformat}
----
Using git bisect on a trivial test case (like the ones above) identified 
SOLR-17044 's commit {{"92edc11dbcf0becc2cd571f078982c78470f15c7"}} as the root 
cause ... but I'm not really familiar enough with all the pieces involved to 
understand how these changes broke the behavior *JUST* for the bare bones 
"HTTP" based SolrClients ... (a similar looking test using 
{{cluster.getSolrClient()}} passes)

I also know that there has been a lot of work on fixing/changing how & when 
URLs and paths are used in the various SolrClient impls to better deal with 
"per-collection" requests vs "global" requests; and v1 api urls vs v2 api urls, 
etc... so it is certainly possible some earlier commit is actually to "blame" 
for the behavior discrepancy between the two types of clients, and SOLR-17044 
just inadvertently "exposed" this discrepancy.

It's also possible that this behavior change was expected/intentional as part 
of the introduction of {{SolrRequest.requiresCollection()}} – but that seems 
unlikely given that the javadocs only mention 
{{SolrClient.getDefaultCollection()}} not 
{{SolrRequest.process(SolrClient,String)}} (and again: the discrepancy between 
types of SolrClients doesn't make sense – if we're intentionally ignoring the 
"collection" param for "http" clients, why aren't we intentionally ignoring 
that param for "cloud" clients?)
----
[~gerlowskija] - can you take a look at this and let me know what 
think/remember about this change?

> GenericSolrRequest.process(client,collection) ignores collection with some 
> client impls
> ---------------------------------------------------------------------------------------
>
>                 Key: SOLR-17866
>                 URL: https://issues.apache.org/jira/browse/SOLR-17866
>             Project: Solr
>          Issue Type: Bug
>    Affects Versions: 9.7, 9.8, 9.9
>            Reporter: Chris M. Hostetter
>            Priority: Major
>
> If you use the {{public final T process(SolrClient client, String 
> collection)}} method of a {{GenericSolrRequest}} the {{collection}} param 
> seems to be ignored (by default) for "single node" {{SolrClient}} impls.
> The problem does not seem to apply when using a "Cloud" based {{SolrClient}} 
> impl.
> This behavior did not exist up to and including 9.6.1
> ----
> A (possible) work around is to call 
> {{GenericSolrRequest.setRequiresCollection(true)}} anytime you know you 
> intend to pass a non-null {{collection}} argument to the {{process(...)}} 
> method
> (I have only verified this work around in a very small number of cases)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to