Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/_termvectors sometimes throws NPE #21928

Closed
shaie opened this issue Dec 2, 2016 · 1 comment
Closed

/_termvectors sometimes throws NPE #21928

shaie opened this issue Dec 2, 2016 · 1 comment

Comments

@shaie
Copy link
Contributor

shaie commented Dec 2, 2016

Spinoff from #21906. I still hope to find the root cause of the NPE, and hopefully this isn't a Guice thing. For reference, here's the stacktrace:

[2016-12-01T11:59:13,208][WARN ][r.suppressed             ] path: /tv_bug/doc/_termvectors, params: {pretty=true, preference=_shards:1, index=tv_bug, type=doc}
org.elasticsearch.transport.RemoteTransportException: [C-N1Zbn][127.0.0.1:9300][indices:data/read/tv[s]]
Caused by: java.lang.NullPointerException
        at org.elasticsearch.action.termvectors.TransportTermVectorsAction.shardOperation(TransportTermVectorsAction.java:79) ~[elasticsearch-5.0.1.jar:5.0.1]
        at org.elasticsearch.action.termvectors.TransportTermVectorsAction.shardOperation(TransportTermVectorsAction.java:42) ~[elasticsearch-5.0.1.jar:5.0.1]
        at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$ShardTransportHandler.messageReceived(TransportSingleShardAction.java:293) ~[elasticsearch-5.0.1.jar:5.0.1]
        at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$ShardTransportHandler.messageReceived(TransportSingleShardAction.java:286) ~[elasticsearch-5.0.1.jar:5.0.1]
        at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33) ~[elasticsearch-5.0.1.jar:5.0.1]
        at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69) ~[elasticsearch-5.0.1.jar:5.0.1]
        at org.elasticsearch.transport.TransportService$6.doRun(TransportService.java:548) [elasticsearch-5.0.1.jar:5.0.1]
        at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:520) [elasticsearch-5.0.1.jar:5.0.1]
        at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-5.0.1.jar:5.0.1]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_92]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_92]
        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_92]

And here's the REST response

{
  "error" : {
    "root_cause" : [
      {
        "type" : "remote_transport_exception",
        "reason" : "[C-N1Zbn][127.0.0.1:9300][indices:data/read/tv[s]]"
      }
    ],
    "type" : "null_pointer_exception",
    "reason" : null
  },
  "status" : 500
}
shaie added a commit to shaie/elasticsearch that referenced this issue Dec 4, 2016
When you submit a _termvectors request for an artificial document and
specify the 'preference' parameter to send the request to a particular
shard, the request sometimes hits NPE. Fix this case by ignoring the
auto-generated artificial document ID and pick a shard per the
preference parameter, or a random shard.

This closes elastic#21928
@shaie
Copy link
Contributor Author

shaie commented Dec 4, 2016

I created a PR to fix the problem: #21959.

The problem is that when you use the _termvectors API with an artificial document and specify the preference parameter, the code used the auto-generated artificial doc's ID and in some cases the shard that was picked for routing per the ID did not match the shardId set in the preference, which resulted in the NPE reported above.

The fix detects that the TV for an artificial document is requested, and if routing isn't explicitly specified, it ignores the document's ID and uses either one of the shards, or the one specified in the preference.

I also added an IT which verifies the behavior; it fails without the fix.

@s1monw s1monw closed this as completed in 6da44c8 Dec 6, 2016
s1monw pushed a commit that referenced this issue Dec 6, 2016
When you submit a _termvectors request for an artificial document and
specify the 'preference' parameter to send the request to a particular
shard, the request sometimes hits NPE. Fix this case by ignoring the
auto-generated artificial document ID and pick a shard per the
preference parameter, or a random shard.

This closes #21928
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant