You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2021/08/16 16:59:00 UTC

[jira] [Commented] (SOLR-12694) JavaBinUpdateRequestCodec fails to restore UpdateRequest.deleteById correctly when '_route_' is specified.

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

ASF subversion and git services commented on SOLR-12694:
--------------------------------------------------------

Commit 5c3465eb498551c53dc310e44ae82cb89890ffc6 in solr's branch refs/heads/main from Chris M. Hostetter
[ https://gitbox.apache.org/repos/asf?p=solr.git;h=5c3465e ]

SOLR-8889: Fixed various problems in Solr and SolrJ that could cause deleteById commands with "_route_" information to processed by the wrong shard, and/or fail when forwarded to replicas from the shard leader.

Portions of this bug and fixes were tracked in SOLR-12694.


> JavaBinUpdateRequestCodec fails to restore UpdateRequest.deleteById correctly when '_route_' is specified.
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: SOLR-12694
>                 URL: https://issues.apache.org/jira/browse/SOLR-12694
>             Project: Solr
>          Issue Type: Bug
>          Components: update
>            Reporter: Yuki Yano
>            Priority: Major
>         Attachments: SOLR-12694.patch
>
>
> h1. Overview
> As reported in [SOLR-7384|https://issues.apache.org/jira/browse/SOLR-7384], when send {{deleteById}} request to Solr with {{ImplicitDocRouter}}, Solr fails to delete the document with the following error.
> {quote}
> org.apache.solr.common.SolrException: missing \_version\_ on update from leader
> {quote}
> This issue is related to [SOLR-5890|https://issues.apache.org/jira/browse/SOLR-5890], which solved the issue about deleting documents with the implicit router. Unfortunately, this change left one bug in {{JavaBinUpdateRequestCodec}} that it forgets to restore {{version}} during {{unmarshal}} if {{\_route\_}} is set.
> {code:java}
>           Long version = (Long) params.get(UpdateRequest.VER);
>           if (params.containsKey(ShardParams._ROUTE_))
>             updateRequest.deleteById(entry.getKey(), (String) params.get(ShardParams._ROUTE_));
>           else
>           updateRequest.deleteById(entry.getKey(), version);
> {code}
> Note that, since this code refers {{\_route\_}} parameter from properties of {{UpdateRequest}}, this error doesn't occur if you use {{\_route\_}} request parameter (like {{/update?\_route\_=foo}}) instead.
> h1. How to reproduce
> 1. start solr cloud with default configuration.
> {code:bash}
> $ ./bin/solr start -e cloud
> {code}
> 2. create new collection (named {{test}} here) with implicit router.
> {code:bash}
> $ curl 'http://localhost:8983/solr/admin/collections?action=CREATE&name=test&router.name=implicit&shards=shard1,shard2&maxShardsPerNode=2&replicationFactor=2'
> {code}
> 3. send add and delete document requests.
> {code:bash}
> // add a document "id=foo" to shard1
> $ curl 'http://localhost:8983/solr/test/update?commit=true&_route_=shard1' -H 'Content-Type: text/xml' --data-binary '<add><doc><field name="id">foo</field></doc></add>'
> // delete the document by using "_route_" request parameter (this is OK)
> $ curl 'http://localhost:8983/solr/test/update?commit=true&_route_=shard1' -H 'Content-Type: text/xml' --data-binary '<delete><id>foo</id></delete>'
> // add a document "id=foo" to shard1 again
> $ curl 'http://localhost:8983/solr/test/update?commit=true&_route_=shard1' -H 'Content-Type: text/xml' --data-binary '<add><doc><field name="id">foo</field></doc></add>'
> // delete the document by using "_route_" attribute (this raises the error mentioned above)
> $ curl 'http://localhost:8983/solr/test/update?commit=true' -H 'Content-Type: text/xml' --data-binary '<delete><id _route_="shard1">foo</id></delete>'
> {code}
> 4. stop solr cloud
> {code:bash}
> $ ./bin/solr stop -all
> {code}
> h1. How to fix
> We can fix this issue by restoring {{UpdateRequest}} with {{version}} correctly like the following code:
> {code:java}
>           Long version = (Long) params.get(UpdateRequest.VER);
>           if (params.containsKey(ShardParams._ROUTE_))
>             updateRequest.deleteById(entry.getKey(), (String) params.get(ShardParams._ROUTE_), version);
>           else
>             updateRequest.deleteById(entry.getKey(), version);
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org