NullPointerException in LongComparator.setTopValue

Hi all,

I get a NullPointerException using Elasticsearch 7.9.1 with Lucene Core 8.6.2 on CentOS 7:

    "stacktrace": ["org.elasticsearch.action.search.SearchPhaseExecutionException: all shards
    failed",
    "at org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseFailure(AbstractSearchAsyncAction.java:551)
    [elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:309)
    [elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseDone(AbstractSearchAsyncAction.java:582)
    [elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.action.search.AbstractSearchAsyncAction.onShardFailure(AbstractSearchAsyncAction.java:393)
    [elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.action.search.AbstractSearchAsyncAction.access$100(AbstractSearchAsyncAction.java:68)
    [elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.action.search.AbstractSearchAsyncAction$1.onFailure(AbstractSearchAsyncAction.java:245)
    [elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.action.search.SearchExecutionStatsCollector.onFailure(SearchExecutionStatsCollector.java:73)
    [elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.action.ActionListenerResponseHandler.handleException(ActionListenerResponseHandler.java:59)
    [elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.action.search.SearchTransportService$ConnectionCountingHandler.handleException(SearchTransportService.java:403)
    [elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.transport.TransportService$6.handleException(TransportService.java:638)
    [elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.transport.TransportService$ContextRestoreResponseHandler.handleException(TransportService.java:1172)
    [elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.transport.TransportService$DirectResponseChannel.processException(TransportService.java:1281)
    [elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.transport.TransportService$DirectResponseChannel.sendResponse(TransportService.java:1255)
    [elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.transport.TaskTransportChannel.sendResponse(TaskTransportChannel.java:61)
    [elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.transport.TransportChannel.sendErrorResponse(TransportChannel.java:56)
    [elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.action.support.ChannelActionListener.onFailure(ChannelActionListener.java:51)
    [elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.search.SearchService.lambda$runAsync$0(SearchService.java:414) [elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:44) [elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:710)
    [elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
    [elasticsearch-7.9.1.jar:7.9.1]",
    "at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) [?:?]",
    "at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) [?:?]",
    "at java.lang.Thread.run(Thread.java:832) [?:?]",
    "Caused by: org.elasticsearch.ElasticsearchException$1: Cannot invoke \"java.lang.Long.longValue()\"
    because \"value\" is null",
    "at org.elasticsearch.ElasticsearchException.guessRootCauses(ElasticsearchException.java:644)
    ~[elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:307)
    [elasticsearch-7.9.1.jar:7.9.1]",
    "... 21 more",
    "Caused by: java.lang.NullPointerException: Cannot invoke \"java.lang.Long.longValue()\" because
    \"value\" is null",
    "at org.apache.lucene.search.FieldComparator$LongComparator.setTopValue(FieldComparator.java:392)
    ~[lucene-core-8.6.2.jar:8.6.2 016993b65e393b58246d54e8ddda9f56a453eb0e - ivera - 2020-08-26
    10:53:36]",
    "at org.apache.lucene.search.FieldComparator$LongComparator.setTopValue(FieldComparator.java:348)
    ~[lucene-core-8.6.2.jar:8.6.2 016993b65e393b58246d54e8ddda9f56a453eb0e - ivera - 2020-08-26
    10:53:36]",
    "at org.apache.lucene.search.TopFieldCollector$PagingFieldCollector.<init>(TopFieldCollector.java:210)
    ~[lucene-core-8.6.2.jar:8.6.2 016993b65e393b58246d54e8ddda9f56a453eb0e - ivera - 2020-08-26
    10:53:36]",
    "at org.apache.lucene.search.TopFieldCollector.create(TopFieldCollector.java:484) ~[lucene-core-8.6.2.jar:8.6.2
    016993b65e393b58246d54e8ddda9f56a453eb0e - ivera - 2020-08-26 10:53:36]",
    "at org.apache.lucene.search.TopFieldCollector.create(TopFieldCollector.java:450) ~[lucene-core-8.6.2.jar:8.6.2
    016993b65e393b58246d54e8ddda9f56a453eb0e - ivera - 2020-08-26 10:53:36]",
    "at org.elasticsearch.search.query.TopDocsCollectorContext$SimpleTopDocsCollectorContext.createCollector(TopDocsCollectorContext.java:217)
    ~[elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.search.query.TopDocsCollectorContext$SimpleTopDocsCollectorContext.<init>(TopDocsCollectorContext.java:267)
    ~[elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.search.query.TopDocsCollectorContext$SimpleTopDocsCollectorContext.<init>(TopDocsCollectorContext.java:210)
    ~[elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.search.query.TopDocsCollectorContext$1.<init>(TopDocsCollectorContext.java:461)
    ~[elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.search.query.TopDocsCollectorContext.createTopDocsCollectorContext(TopDocsCollectorContext.java:461)
    ~[elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.search.query.QueryPhase.searchWithCollector(QueryPhase.java:329) ~[elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.search.query.QueryPhase.executeInternal(QueryPhase.java:298) ~[elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:150) ~[elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.search.SearchService.loadOrExecuteQueryPhase(SearchService.java:362)
    ~[elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:435) ~[elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.search.SearchService.access$200(SearchService.java:136) ~[elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.search.SearchService$2.lambda$onResponse$0(SearchService.java:396) ~[elasticsearch-7.9.1.jar:7.9.1]",
    "at org.elasticsearch.search.SearchService.lambda$runAsync$0(SearchService.java:412) ~[elasticsearch-7.9.1.jar:7.9.1]",
    "... 6 more"]

Unfortunately, I cannot provide any further reproduction hints.
Since the request causing this might contain confidential information, I prefer not to share it at this time.

I have already posted this issue on the Lucene mailing list (here) and got the reply that it might be an issue in Elasticsearch.

Should I file a bug on GitHub for this?

Thanks and best regards,
Michael

Welcome!

Would it be possible first to upgrade to latest 7.11.2 version? In case this issue has been fixed in the meantime?
But yes IMO it is worth it to report an issue as a NPE is never a good thing :slight_smile:

Thanks!