Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-9406

SolrSuggester should selectively register close hook

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Resolved
    • Affects Version/s: 4.10.3
    • Fix Version/s: 6.3
    • Component/s: Suggester
    • Security Level: Public (Default Security Level. Issues are Public)
    • Labels:
      None

      Description

      Currently this is the code for registering a close hook for SolrSuggester:

      lookup = factory.create(config, core);
          core.addCloseHook(new CloseHook() {
            @Override
            public void preClose(SolrCore core) {
              if (lookup != null && lookup instanceof Closeable) {
                try {
                  ((Closeable) lookup).close();
                } catch (IOException e) {
                  LOG.warn("Could not close the suggester lookup.", e);
                }
              }
            }
            
            @Override
            public void postClose(SolrCore core) {}
          });
      

      Notice that the close hook is always registered, even though the close logic runs conditionally.

      This can be changed so that the close hook is registered conditionally.

      This will help avoid memory leaks in scenarios where a custom component reloads the SolrSuggester multiple times for the same core.

      1. SOLR-9406.patch
        1 kB
        Joel Bernstein

        Activity

        Hide
        covolution Gethin James added a comment -

        A potential solution would be to put the following around the closehook creation:

        if (lookup != null && lookup instanceof Closeable) {
        }
        Show
        covolution Gethin James added a comment - A potential solution would be to put the following around the closehook creation: if (lookup != null && lookup instanceof Closeable) { }
        Hide
        joel.bernstein Joel Bernstein added a comment -

        Un-assigning myself in case anyone else wants to take this. If no one does then I'll help move this forward.

        Show
        joel.bernstein Joel Bernstein added a comment - Un-assigning myself in case anyone else wants to take this. If no one does then I'll help move this forward.
        Hide
        joel.bernstein Joel Bernstein added a comment -

        Simple patch to conditionally register the close hook. The conditional logic is the same, it's just moved outside of the close hook itself, to control the close hook registration.

        Show
        joel.bernstein Joel Bernstein added a comment - Simple patch to conditionally register the close hook. The conditional logic is the same, it's just moved outside of the close hook itself, to control the close hook registration.
        Hide
        joel.bernstein Joel Bernstein added a comment - - edited

        Shoot, I put the wrong jira ticket on the commit. I used SEARCH-9406 instead of SOLR-9406. SEARCH is what we use at alfresco to prefix search tickets.

        The master commit was:
        https://github.com/apache/lucene-solr/commit/a1b55eb743a6826299f155f95e41676fc33b576a
        The branch_6x commit was:
        https://github.com/apache/lucene-solr/commit/171f633616de4e7778894166ee6fcb45fd8a23cf

        Show
        joel.bernstein Joel Bernstein added a comment - - edited Shoot, I put the wrong jira ticket on the commit. I used SEARCH-9406 instead of SOLR-9406 . SEARCH is what we use at alfresco to prefix search tickets. The master commit was: https://github.com/apache/lucene-solr/commit/a1b55eb743a6826299f155f95e41676fc33b576a The branch_6x commit was: https://github.com/apache/lucene-solr/commit/171f633616de4e7778894166ee6fcb45fd8a23cf
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 4c0ff4e0f1105f3b81346bc680493832ffbae69c in lucene-solr's branch refs/heads/master from jbernste
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=4c0ff4e ]

        SOLR-9406: Update CHANGES.txt

        Show
        jira-bot ASF subversion and git services added a comment - Commit 4c0ff4e0f1105f3b81346bc680493832ffbae69c in lucene-solr's branch refs/heads/master from jbernste [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=4c0ff4e ] SOLR-9406 : Update CHANGES.txt
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 69e22ae4eccef1833183fd3b0fe5302c19efd79c in lucene-solr's branch refs/heads/branch_6x from jbernste
        [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=69e22ae ]

        SOLR-9406: Update CHANGES.txt

        Show
        jira-bot ASF subversion and git services added a comment - Commit 69e22ae4eccef1833183fd3b0fe5302c19efd79c in lucene-solr's branch refs/heads/branch_6x from jbernste [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=69e22ae ] SOLR-9406 : Update CHANGES.txt
        Hide
        shalinmangar Shalin Shekhar Mangar added a comment -

        Closing after 6.3.0 release.

        Show
        shalinmangar Shalin Shekhar Mangar added a comment - Closing after 6.3.0 release.

          People

          • Assignee:
            joel.bernstein Joel Bernstein
            Reporter:
            covolution Gethin James
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development