Lucene - Core
  1. Lucene - Core
  2. LUCENE-7002

MultiCollector throws NPE when there is CollectTerminatedException is thrown by a subcollector

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.4
    • Fix Version/s: 5.5, 5.4.2
    • Component/s: core/search
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      I am seeing this in our log:

      Caused by: java.lang.NullPointerException
              at org.apache.lucene.search.MultiCollector$MultiLeafCollector.setScorer(MultiCollector.java:156)
              at org.apache.lucene.search.BooleanScorer$1$1.setScorer(BooleanScorer.java:50)
              at org.apache.lucene.search.Weight$DefaultBulkScorer.score(Weight.java:166)
              at org.apache.lucene.search.BooleanScorer$1.score(BooleanScorer.java:59)
              at org.apache.lucene.search.BooleanScorer$BulkScorerAndDoc.score(BooleanScorer.java:90)
              at org.apache.lucene.search.BooleanScorer.scoreWindowSingleScorer(BooleanScorer.java:313)
              at org.apache.lucene.search.BooleanScorer.scoreWindow(BooleanScorer.java:336)
              at org.apache.lucene.search.BooleanScorer.score(BooleanScorer.java:364)
              at org.apache.lucene.search.BulkScorer.score(BulkScorer.java:39)
              at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:821)
              at org.apache.lucene.search.IndexSearcher$5.call(IndexSearcher.java:763)
              at org.apache.lucene.search.IndexSearcher$5.call(IndexSearcher.java:760)
              at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      

      Looks like

      MultiCollector.removeCollector(i)
      

      is called on line 176, the loop:

      for (LeafCollector c : collectors) {
              c.setScorer(scorer);
      }
      

      in setScorer can still step on it, on line 155.

      I am however, unable to reproduce that with a unit test.

      I made a copy of this class and added a null check in setScorer() and the problem goes away.

        Activity

        Hide
        John Wang added a comment -

        Adrien Grand Looks like this might be related to LUCENE-6772?

        Show
        John Wang added a comment - Adrien Grand Looks like this might be related to LUCENE-6772 ?
        Hide
        Adrien Grand added a comment -

        Thanks John, this looks related indeed! I believe this may happen with bulk scorer impls that may call setScorer after collection already started (like BS1). I'll work on a fix.

        Show
        Adrien Grand added a comment - Thanks John, this looks related indeed! I believe this may happen with bulk scorer impls that may call setScorer after collection already started (like BS1). I'll work on a fix.
        Hide
        Adrien Grand added a comment -

        Here is a patch.

        Show
        Adrien Grand added a comment - Here is a patch.
        Hide
        ASF subversion and git services added a comment -

        Commit 11afd639c38be1de15fce46c034b2c9a8fff3255 in lucene-solr's branch refs/heads/branch_5x from Adrien Grand
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=11afd63 ]

        LUCENE-7002: Fixed MultiCollector to not throw a NPE if setScorer is called after one of the sub collectors is done collecting.

        Show
        ASF subversion and git services added a comment - Commit 11afd639c38be1de15fce46c034b2c9a8fff3255 in lucene-solr's branch refs/heads/branch_5x from Adrien Grand [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=11afd63 ] LUCENE-7002 : Fixed MultiCollector to not throw a NPE if setScorer is called after one of the sub collectors is done collecting.
        Hide
        ASF subversion and git services added a comment -

        Commit 5e6f22b925add09dc20b7d53bf8f177a582a4ed1 in lucene-solr's branch refs/heads/master from Adrien Grand
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=5e6f22b ]

        LUCENE-7002: Fixed MultiCollector to not throw a NPE if setScorer is called after one of the sub collectors is done collecting.

        Show
        ASF subversion and git services added a comment - Commit 5e6f22b925add09dc20b7d53bf8f177a582a4ed1 in lucene-solr's branch refs/heads/master from Adrien Grand [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=5e6f22b ] LUCENE-7002 : Fixed MultiCollector to not throw a NPE if setScorer is called after one of the sub collectors is done collecting.
        Hide
        Michael McCandless added a comment -

        Reopen for backport to 5.4.2.

        Show
        Michael McCandless added a comment - Reopen for backport to 5.4.2.
        Hide
        ASF subversion and git services added a comment -

        Commit 96624a676f5f2bfe3f267e6c1db889e2fe7a1781 in lucene-solr's branch refs/heads/branch_5_4 from Adrien Grand
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=96624a6 ]

        LUCENE-7002: Fixed MultiCollector to not throw a NPE if setScorer is called after one of the sub collectors is done collecting.

        Conflicts:
        lucene/CHANGES.txt

        Show
        ASF subversion and git services added a comment - Commit 96624a676f5f2bfe3f267e6c1db889e2fe7a1781 in lucene-solr's branch refs/heads/branch_5_4 from Adrien Grand [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=96624a6 ] LUCENE-7002 : Fixed MultiCollector to not throw a NPE if setScorer is called after one of the sub collectors is done collecting. Conflicts: lucene/CHANGES.txt

          People

          • Assignee:
            Adrien Grand
            Reporter:
            John Wang
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development