lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yonik Seeley (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (SOLR-5360) Correctly routed realtime-get through CloudSolrServer
Date Thu, 17 Oct 2013 19:24:43 GMT

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

Yonik Seeley commented on SOLR-5360:
------------------------------------

bq. Be careful serving RTGs from non-leaders. It can lead to inconsistency between version-conflicts
from update-requests and what you get from you RTG on the same document. But probably not
a big problem i practice.

Seems like optimistic concurrency should still work, even if the RTG is served from a non-leader.
 It's just that it's inefficient (could lead to many more retries than necessary).

> Correctly routed realtime-get through CloudSolrServer
> -----------------------------------------------------
>
>                 Key: SOLR-5360
>                 URL: https://issues.apache.org/jira/browse/SOLR-5360
>             Project: Solr
>          Issue Type: New Feature
>          Components: SolrCloud
>    Affects Versions: 4.5
>            Reporter: Per Steffensen
>            Assignee: Per Steffensen
>              Labels: get, realtime
>             Fix For: 4.6
>
>         Attachments: SOLR-5360.patch
>
>
> Today you cannot do realtime-gets through CloudSolrServer, because it will not route
the request to the correct replica (the leader-replica of the shard where the document to
be fetched lives according to routing rules)
> Doing realtime-gets from clients are important in several scenarios. For example in common
optimistic locking scenario. Pseudo-code:
> {code}
> public void createOrUpdateDoc(String id, ChangeInfo changes) {
>     outherLoop: while(true) {
>         try {
>             // Assume that document with id does not exist already
>             // Just try to store it as a new document
>             SolrInputDocument newDoc = createNewSolrInputDocument(id, changes); 
>             sendUpdateRequestToSolr(newDoc);
>             return;
>         } catch (DocumentAlreadyExists e) {
>             // Ok the document already existed
>             while(true) {
>                 // Fetch the existing document - realtime-get so that you do not
>                 // have to wait until next commit to be able to fetch it, if the document
>                 // was created/updated after last commit
>                 SolrDocument fetchedDoc = realTimeGet(id);
>                 // Merge the changes into the existing document
>                 // Including copy of _version_ from fetchedDoc to updatedDoc
>                 SolrInputDocument updatedDoc = merge(fetchedDoc, changes);
>                 // Try to store the updated document
>                 try {
>                     sendUpdateRequestToSolr(updatedDoc);
>                     return;
>                 } catch (VersionConflict e) {
>                     // Someone updated the doc, between my fetch and update
>                     // Ignore, just take another round in the inner while(true)-loop
>                 } catch (DocumentDoesNotExist e) {
>                     // Someone deleted the document since when I tried to
>                     // create it as a new document the first time
>                     // Will create it again by taking another round in outher
>                     // while(true)-loop
>                     continue outherLoop;
>                 }
>             }
>         }
>     }
> }
> {code}
> Sorry if the code is not perfect, but I just wrote it directly here - I sure you get
the idea.
> I would like to enable realtime-get through CloudSolrServer in order to be able to do
scenarios as e.g. the one shown above



--
This message was sent by Atlassian JIRA
(v6.1#6144)

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


Mime
View raw message