Solr
  1. Solr
  2. SOLR-6864

Support registering searcher listeners in SolrCoreAware.inform(SolrCore) method

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.0, 6.0
    • Fix Version/s: 5.0, 6.0
    • Component/s: None
    • Labels:
      None

      Description

      I'm marking this Jira as Bug because we already have components that do this (SuggestComponent and SpellcheckComponent), however, listeners registered at this stage not always work.
      From https://issues.apache.org/jira/browse/SOLR-6845?focusedCommentId=14250350&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14250350

      Trying to add some unit tests to this feature I found another issue. SuggestComponent and SpellcheckComponent rely on a firstSearcherListener to load (and in this case, also build) some structures. These firstSearcherListeners are registered on SolrCoreAware.inform(), however the first searcher listener task is only added to the queue of warming tasks if there is at least one listener registered at the time of the first searcher creation (before SolrCoreAware.inform() is ever called). See

      SolrCore.java
              if (currSearcher == null && firstSearcherListeners.size() > 0) {
                future = searcherExecutor.submit(new Callable() {
                  @Override
                  public Object call() throws Exception {
                    try {
                      for (SolrEventListener listener : firstSearcherListeners) {
                        listener.newSearcher(newSearcher, null);
                      }
                    } catch (Throwable e) {
                      SolrException.log(log, null, e);
                      if (e instanceof Error) {
                        throw (Error) e;
                      }
                    }
                    return null;
                  }
                });
              }
      

      I'll create a new Jira for this

      1. fix.patch
        3 kB
        Tomás Fernández Löbbe
      2. SOLR-6864.patch
        9 kB
        Tomás Fernández Löbbe
      3. SOLR-6864-tests.patch
        10 kB
        Tomás Fernández Löbbe

        Activity

        Hide
        ASF subversion and git services added a comment -

        Commit 1646577 from Tomás Fernández Löbbe in branch 'dev/trunk'
        [ https://svn.apache.org/r1646577 ]

        SOLR-6864: Support registering searcher listeners in SolrCoreAware.inform(SolrCore) method

        Show
        ASF subversion and git services added a comment - Commit 1646577 from Tomás Fernández Löbbe in branch 'dev/trunk' [ https://svn.apache.org/r1646577 ] SOLR-6864 : Support registering searcher listeners in SolrCoreAware.inform(SolrCore) method
        Hide
        ASF subversion and git services added a comment -

        Commit 1646581 from Tomás Fernández Löbbe in branch 'dev/branches/branch_5x'
        [ https://svn.apache.org/r1646581 ]

        SOLR-6864: Support registering searcher listeners in SolrCoreAware.inform(SolrCore) method

        Show
        ASF subversion and git services added a comment - Commit 1646581 from Tomás Fernández Löbbe in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1646581 ] SOLR-6864 : Support registering searcher listeners in SolrCoreAware.inform(SolrCore) method
        Hide
        Hoss Man added a comment -

        i''ve got a seed here that causes the newly added test to fail 100% of the time on trunk...

           [junit4]   2> NOTE: reproduce with: ant test  -Dtestcase=TestIndexSearcher -Dtests.method=testSearcherListeners -Dtests.seed=72D3132D566B9448 -Dtests.slow=true -Dtests.locale=es_PR -Dtests.timezone=America/Blanc-Sablon -Dtests.asserts=true -Dtests.file.encoding=UTF-8
           [junit4] FAILURE 0.86s | TestIndexSearcher.testSearcherListeners <<<
           [junit4]    > Throwable #1: java.lang.AssertionError: expected:<1> but was:<0>
           [junit4]    > 	at __randomizedtesting.SeedInfo.seed([72D3132D566B9448:DB7AC2090729EE8C]:0)
           [junit4]    > 	at org.apache.solr.search.TestIndexSearcher.createCoreAndValidateListeners(TestIndexSearcher.java:219)
           [junit4]    > 	at org.apache.solr.search.TestIndexSearcher.testSearcherListeners(TestIndexSearcher.java:194)
           [junit4]    > 	at java.lang.Thread.run(Thread.java:745)
        
        Show
        Hoss Man added a comment - i''ve got a seed here that causes the newly added test to fail 100% of the time on trunk... [junit4] 2> NOTE: reproduce with: ant test -Dtestcase=TestIndexSearcher -Dtests.method=testSearcherListeners -Dtests.seed=72D3132D566B9448 -Dtests.slow=true -Dtests.locale=es_PR -Dtests.timezone=America/Blanc-Sablon -Dtests.asserts=true -Dtests.file.encoding=UTF-8 [junit4] FAILURE 0.86s | TestIndexSearcher.testSearcherListeners <<< [junit4] > Throwable #1: java.lang.AssertionError: expected:<1> but was:<0> [junit4] > at __randomizedtesting.SeedInfo.seed([72D3132D566B9448:DB7AC2090729EE8C]:0) [junit4] > at org.apache.solr.search.TestIndexSearcher.createCoreAndValidateListeners(TestIndexSearcher.java:219) [junit4] > at org.apache.solr.search.TestIndexSearcher.testSearcherListeners(TestIndexSearcher.java:194) [junit4] > at java.lang.Thread.run(Thread.java:745)
        Hide
        Tomás Fernández Löbbe added a comment -

        I'll take a look

        Show
        Tomás Fernández Löbbe added a comment - I'll take a look
        Hide
        Tomás Fernández Löbbe added a comment -

        I think this is not a seed issue, it's a race condition. It never failed on my mac after hundreds of iterations, It did (with this seed and others) fail in other hosts where I ran the tests.
        Adding some sleep time in the mock listeners I can reproduce it on my mac. I'll commit a fix shortly

        Show
        Tomás Fernández Löbbe added a comment - I think this is not a seed issue, it's a race condition. It never failed on my mac after hundreds of iterations, It did (with this seed and others) fail in other hosts where I ran the tests. Adding some sleep time in the mock listeners I can reproduce it on my mac. I'll commit a fix shortly
        Hide
        Tomás Fernández Löbbe added a comment -

        Here is my fix. I ran the test 600 times in three different hosts and all passed

        Show
        Tomás Fernández Löbbe added a comment - Here is my fix. I ran the test 600 times in three different hosts and all passed
        Hide
        ASF subversion and git services added a comment -

        Commit 1646918 from Tomás Fernández Löbbe in branch 'dev/trunk'
        [ https://svn.apache.org/r1646918 ]

        SOLR-6864: Fix test race condition, make test wait for warming in TestIndexSearcher

        Show
        ASF subversion and git services added a comment - Commit 1646918 from Tomás Fernández Löbbe in branch 'dev/trunk' [ https://svn.apache.org/r1646918 ] SOLR-6864 : Fix test race condition, make test wait for warming in TestIndexSearcher
        Hide
        ASF subversion and git services added a comment -

        Commit 1646919 from Tomás Fernández Löbbe in branch 'dev/branches/branch_5x'
        [ https://svn.apache.org/r1646919 ]

        SOLR-6864: Fix test race condition, make test wait for warming in TestIndexSearcher

        Show
        ASF subversion and git services added a comment - Commit 1646919 from Tomás Fernández Löbbe in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1646919 ] SOLR-6864 : Fix test race condition, make test wait for warming in TestIndexSearcher
        Hide
        Tomás Fernández Löbbe added a comment -

        There were no failures since the last commit. While looking at these failures I also added unit tests for useColdSearcher that I think can be part of this Jira. Attaching patch

        Show
        Tomás Fernández Löbbe added a comment - There were no failures since the last commit. While looking at these failures I also added unit tests for useColdSearcher that I think can be part of this Jira. Attaching patch
        Hide
        ASF subversion and git services added a comment -

        Commit 1647836 from Tomás Fernández Löbbe in branch 'dev/trunk'
        [ https://svn.apache.org/r1647836 ]

        SOLR-6864: Improved tests, added useColdSearcher test case

        Show
        ASF subversion and git services added a comment - Commit 1647836 from Tomás Fernández Löbbe in branch 'dev/trunk' [ https://svn.apache.org/r1647836 ] SOLR-6864 : Improved tests, added useColdSearcher test case
        Hide
        ASF subversion and git services added a comment -

        Commit 1647837 from Tomás Fernández Löbbe in branch 'dev/branches/branch_5x'
        [ https://svn.apache.org/r1647837 ]

        SOLR-6864: Improved tests, added useColdSearcher test case

        Show
        ASF subversion and git services added a comment - Commit 1647837 from Tomás Fernández Löbbe in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1647837 ] SOLR-6864 : Improved tests, added useColdSearcher test case
        Hide
        Anshum Gupta added a comment -

        Bulk close after 5.0 release.

        Show
        Anshum Gupta added a comment - Bulk close after 5.0 release.
        Hide
        Erick Erickson added a comment -

        re-opening for inclusion in 4.10.5

        Show
        Erick Erickson added a comment - re-opening for inclusion in 4.10.5
        Hide
        Erick Erickson added a comment -

        Decided not to back-port to 4.10.5, it was more complex than I thought.

        Show
        Erick Erickson added a comment - Decided not to back-port to 4.10.5, it was more complex than I thought.

          People

          • Assignee:
            Erick Erickson
            Reporter:
            Tomás Fernández Löbbe
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development