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

David Smiley commented on SOLR-12258:
-------------------------------------

Thanks for the input.  Here's another variation of this method; this time 
without a secondTry arg which I don't really like:
{code:java}
  protected DocCollection resolveDocCollection(String collectionStr) {
    if (!cores.isZooKeeperAware()) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Solr not 
running in cloud mode ");
    }
    ZkStateReader zkStateReader = cores.getZkController().getZkStateReader();
    
    Supplier<DocCollection> logic = () -> {
      this.collectionsList = resolveCollectionListOrAlias(collectionStr); // 
side-effect
      String collectionName = collectionsList.get(0); // first
      //TODO an option to choose another collection in the list if can't find a 
local replica of the first?

      return 
zkStateReader.getClusterState().getCollectionOrNull(collectionName);
    };
    
    DocCollection docCollection = logic.get();
    if (docCollection != null) {
      return docCollection;
    }
    // ensure our view is up to date before trying again
    try {
      zkStateReader.aliasesManager.update();
      zkStateReader.forceUpdateCollection(collectionsList.get(0));
    } catch (Exception e) {
      log.error("Error trying to update state while resolving collection.", e);
      //don't propagate exception on purpose
    }
    return logic.get();
  }
{code}
I can't come up with anything elegant.  At least the lambda had little ceremony 
to it, helped by the fact that no checked exceptions are involved and so I 
could use the standard Supplier interface.


bq. forciblyRefreshAllClusterStateSlow

Heh; I didn't notice it.  It sure does look like a candidate!  Yeah, adding 
sync() over there ought to be its own JIRA.

> V2 API should "retry" for unresolved collections/aliases (like V1 does)
> -----------------------------------------------------------------------
>
>                 Key: SOLR-12258
>                 URL: https://issues.apache.org/jira/browse/SOLR-12258
>             Project: Solr
>          Issue Type: Improvement
>      Security Level: Public(Default Security Level. Issues are Public) 
>          Components: SolrCloud, v2 API
>            Reporter: David Smiley
>            Priority: Major
>         Attachments: SOLR-12258.patch, SOLR-12258.patch
>
>
> When using V1, if the request refers to a possible collection/alias that 
> fails to resolve, HttpSolrCall will invoke AliasesManager.update() then retry 
> the request as if anew (in collaboration with SolrDispatchFilter).  If it 
> fails to resolve again we stop there and return an error; it doesn't go on 
> forever.
> V2 (V2HttpCall specifically) doesn't have this retry mechanism.  It'll return 
> "no such collection or alias".
> The retry will not only work for an alias but the retrying is a delay that 
> will at least help the odds of a newly made collection from being known to 
> this Solr node.  It'd be nice if this was more explicit – i.e. if there was a 
> mechanism similar to AliasesManager.update() but for a collection.  I'm not 
> sure how to do that?
> BTW I discovered this while debugging a Jenkins failure of 
> TimeRoutedAliasUpdateProcessorTest.test where it early on simply goes to 
> issue a V2 based request to change the configuration of a collection that was 
> created immediately before it.  It's pretty mysterious.  I am aware of 
> SolrCloudTestCase.waitForState which is maybe something that needs to be 
> called?  But if that were true then *every* SolrCloud test would need to use 
> it; it just seems wrong to me that we ought to use this method commonly.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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

Reply via email to