You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Yuki Yano (JIRA)" <ji...@apache.org> on 2018/08/24 06:49:00 UTC
[jira] [Created] (SOLR-12694) JavaBinUpdateRequestCodec fails to
restore UpdateRequest correctly with implicit routing
Yuki Yano created SOLR-12694:
--------------------------------
Summary: JavaBinUpdateRequestCodec fails to restore UpdateRequest correctly with implicit routing
Key: SOLR-12694
URL: https://issues.apache.org/jira/browse/SOLR-12694
Project: Solr
Issue Type: Bug
Security Level: Public (Default Security Level. Issues are Public)
Components: update
Reporter: Yuki Yano
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
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org